#include <bits/stdc++.h>
using namespace std;
function<void(void)> ____ = []() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
};
int n;
set<int, greater<int>> S;
int main() {
  ____();
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int tp;
    cin >> tp;
    S.insert(tp);
  }
  while (true) {
    bool ok = false;
    int p = *S.begin();
    while (p) {
      if (S.count(p))
        p >>= 1;
      else {
        ok = true;
        S.erase(S.begin());
        S.insert(p);
        break;
      }
    }
    if (!ok) break;
  }
  for (auto p : S) cout << p << ' ';
  cout << endl;
  return 0;
}
