#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
int arr1[n];
for ( int i = 0 ; i < n ; i ++ )
{
cin >> arr1[i];
}
int tedad = 0;
for ( int i = 0 ; i < n ; i ++ )
{
if ( arr1[i] == 0 )
{
tedad ++;
}
}
int arr2[n - tedad];
int m = 0;
for ( int i = 0 ; i < n ; i ++ )
{
if ( arr1[i] != 0 )
{
arr2[m] = arr1[i];
m ++;
}
}
for ( int i = 0 ; i < n ; i ++ )
{
if ( i < n - tedad )
{
cout << arr2[i] <<" ";
}
else
{
cout << '0' <<" ";
}
}
return 0;
}