#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
int arr[n];
for ( int i = 0 ; i < n ; i ++ )
{
cin >> arr[i];
}
int tedad = 0;
for ( int a = 0 ; a < n ; a ++ )
{
if ( arr[a] == 0 )
{
tedad ++;
}
}
int x = n - 1;
for ( int b = 0 ; b < n - tedad ; b ++ )
{
if ( arr[b] == 0 )
{
swap ( arr[b] , arr[x] );
x --;
}
}
for ( int i = 0 ; i < n ; i ++ )
{
cout << arr[i] <<" ";
}
return 0;
}