#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 17;
set<int> a, b, ans;
bool check(int x) {
  b.clear();
  if (a.find(x) != a.end()) b.insert(x);
  for (set<int>::iterator it = a.begin(); it != a.lower_bound(x); ++it) {
    b.insert(*it);
  }
  for (set<int>::iterator it = a.upper_bound(x); it != a.end(); ++it) {
    int now = *it;
    bool have = false;
    while (now > 0) {
      if (now > x)
        now /= 2;
      else {
        if (b.find(now) == b.end()) {
          b.insert(now);
          have = true;
          break;
        } else
          now /= 2;
      }
    }
    if (!have) return false;
  }
  ans = b;
  return true;
}
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int tmp;
    cin >> tmp;
    a.insert(tmp);
  }
  int l = 0, r = *a.rbegin() + 100;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (check(mid))
      r = mid;
    else
      l = mid;
  }
  for (auto i : ans) cout << i << endl;
  return 0;
}
