#include <iostream>
using namespace std;
int main()
{
int n , x , counter;
cin >> n;
counter = 0;
for ( int i = 0 ; i < n ; i ++ )
{
cin >> x;
if ( x != 0 )
{
cout << x <<" ";
}
else if ( x == 0 )
{
counter ++;
}
}
for ( int i = 0 ; i < counter ; i ++ )
{
cout <<'0';
}
return 0;
}