#include <bits/stdc++.h>   using namespace std;   int n, i, ans;   map<long long, long long> m, ind;   long long b[150001], a;   int main() {     scanf( %d , &n);     ans = n;     for (i = 1; i <= n; i++) {       scanf( %I64d , &a);       m[a]++;       b[i] = a;       while (m[a] > 1) {         ans--;         m[a] = 0;         b[ind[a]] = 0;         a *= 2;         b[i] = a;         m[a]++;       }       ind[a] = i;     }     printf( %d n , ans);     for (i = 1; i <= n; i++)       if (b[i] > 0) printf( %I64d  , b[i]);     return 0;   }   