#include <stdio.h>
#include <stdlib.h>
#define N 1000 //双指针思想
int main(int argc, char *argv[])
{
int n;
int s[N];
scanf("%d",&n);
for(int i = 0 ; i < n ; i++)
scanf("%d",&s[i]);
int j = 0;
for(int i = 0 ; i < n ; i++)
{
if(s[i] != 0 )
{
int t = s[j];
s[j++] = s[i];
s[i] = t;
}
}
for(int i = 0 ; i < n ; i++)
printf("%d ",s[i]);
return 0;
}