Move Zeros to the End

Program to move all zero's to the end of list.

n = int(input())
li = list(map(int,input().split()))[:n]
for i in range(n):
    if li[i]==0:
        li.append(0)
        li.remove(0)
print(*li)

Input
6
1 0 0 2 0 4
Output
1 2 4 0 0 0