#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, j;
  cin >> n;
  long long x;
  map<long long, long long> mp;
  priority_queue<long long> q;
  for (i = 0; i < n; i++) {
    cin >> x;
    q.push(x);
    mp[x]++;
  }
  vector<long long> ans;
  while (!q.empty()) {
    long long f = q.top();
    q.pop();
    long long last = f;
    long long t = 1;
    while (f > 1) {
      f /= 2;
      if (mp[f] == 0) {
        mp[last]--;
        mp[f]++;
        q.push(f);
        t = 0;
        break;
      }
    }
    if (t) ans.push_back(last);
  }
  for (auto it : ans) cout << it << ' ';
  return 0;
}
