# your code goes here n=int(input()) l=[0]*n j=0 for i in range(n): a=int(input()) if(a!=0): l[j]=a j+=1 print(l)