#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 ; b ++ )
    {
        if ( arr[b] == 0 )
        {
           for ( int z = 0 ; z < tedad ; z ++ )
           {
               if ( arr[b] != arr[x])
               {
                swap ( arr[b] , arr[x] );
                x --;
               }
           }
        }
    }

    for ( int i = 0 ; i < n ; i ++ )
    {
        cout << arr[i] <<" ";
    }


    return 0;
}