#include <iostream>
using namespace std;
int move(int a[], int n){
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;
}
int main(){
int n;
cout << "No.of elements \n";
cin >> n;
int a[n];
cout << "Enter the elements \n";
for (int i = 0;i<n;i++)
cin >> a[i];
for (int i = 0;i < n-1;i++)
if (a[i] == a[i+1]){
a[i] *= 2;
a[i+1] = 0;
}
move(a,n);
for(int i = 0;i<n;i++)
cout << a[i] << " ";
}