n=int(input())
arr=[]
for_in range(n);
   arr.append(int(input()))
   if 0 not in arr:
      pront("invalid input")
   else:
       non_zero=[x for x in arr if x!=0]
       zeros=[0]*arr.count(0)
       result = non_zero+zeros
       print(*result)