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