#include <bits/stdc++.h>
using namespace std;
set<int> s;
int a[1000000], n;
bool can(int x) {
  s.clear();
  for (int i = 0; i < n; i++) {
    vector<int> path;
    int temp = a[i];
    while (temp) {
      path.push_back(temp);
      temp >>= 1;
    }
    sort(path.rbegin(), path.rend());
    bool was = 0;
    for (int j = 0; j < path.size(); j++) {
      if (path[j] <= x && s.find(path[j]) == s.end()) {
        s.insert(path[j]);
        was = 1;
        break;
      }
    }
    if (!was) return 0;
  }
  return 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  int l = 1, r = (int)1e9;
  while (l < r) {
    int c = (1LL * l + 1LL * r) / 2LL;
    if (can(c))
      r = c;
    else
      l = c + 1;
  }
  can(l);
  for (auto it = s.begin(); it != s.end(); it++) {
    cout << *it << " ";
  }
  return 0;
}
