#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> y(n);
  set<int> x;
  for (int i = 0; i < n; ++i) {
    cin >> y[i];
    x.insert(y[i]);
  }
  while (true) {
    bool done = true;
    auto it = --x.end();
    int cur = *it;
    vector<int> tmp;
    while (cur != 1) {
      cur /= 2;
      tmp.push_back(cur);
    }
    for (int m : tmp) {
      if (x.count(m) == 0) {
        x.erase(it);
        x.insert(m);
        done = false;
        break;
      }
    }
    if (done) break;
  }
  for (int xx : x) cout << xx << ' ';
  cout << endl;
  return 0;
}
