#include <iostream>
using namespace std;
int main(){
int n;
cout << "No.of elements:";
cin >> n;
int a[n];
cout << "Enter the elements:\n";
for (int i = 0; i < n;i++)
cin >> a[i];
int count = 0;
for (int i = 0; i < n;i++)
if (a[i] != 0)
a[count++] = a[i];
for(int i=count; i < n; i++)
a[i] = 0;
for (int i = 0; i < n;i++)
cout << a[i] << " ";
}