#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a;
set<int> used;
bool check(int maxx) {
  used.clear();
  for (auto item : a) used.insert(item);
  for (auto temp : a) {
    int res = -1;
    int t = temp;
    if (temp <= maxx) continue;
    used.erase(temp);
    while (temp) {
      if (temp % 2 == 0)
        temp = temp / 2;
      else
        temp = (temp - 1) / 2;
      if (temp > 0 && temp <= maxx && (used.find(temp) == used.end())) {
        res = temp;
        break;
      }
    }
    if (res == -1) return false;
    used.insert(res);
  }
  return used.size() == n;
}
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  cin >> n;
  a.resize(n);
  for (auto &it : a) cin >> it;
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int l = 1;
  int r = a[0];
  set<int> res;
  while (l <= r) {
    int mid = (l + r) / 2;
    bool c = check(mid);
    if (c)
      res = used, r = mid - 1;
    else
      l = mid + 1;
  }
  for (auto item : res) cout << item << " ";
  cout << endl;
}
