#include <bits/stdc++.h>
using namespace std;
bool check(int high, vector<int> &v, vector<vector<int> > &g) {
  unordered_set<int> used;
  for (int i = 0; i < v.size(); i++) {
    bool added = false;
    for (int j = 0; j < g[i].size(); j++) {
      if (g[i][j] <= high && used.count(g[i][j]) == 0) {
        used.insert(g[i][j]);
        added = true;
        break;
      }
    }
    if (!added) return false;
  }
  return true;
}
unordered_set<int> go(int high, vector<int> &v, vector<vector<int> > &g) {
  unordered_set<int> used;
  for (int i = 0; i < v.size(); i++) {
    bool added = false;
    for (int j = 0; j < g[i].size(); j++) {
      if (g[i][j] <= high && used.count(g[i][j]) == 0) {
        used.insert(g[i][j]);
        added = true;
        break;
      }
    }
  }
  return used;
}
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  vector<vector<int> > g(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.rbegin(), v.rend());
  for (int i = 0; i < n; i++) {
    int cur = v[i];
    while (cur > 0) {
      g[i].push_back(cur);
      cur /= 2;
    }
  }
  int lo = 1, hi = 1000000000;
  while (lo < hi) {
    int c = (lo + hi) / 2;
    if (check(c, v, g))
      hi = c;
    else
      lo = c + 1;
  }
  auto res = go(lo, v, g);
  for (auto i : res) {
    cout << i << " ";
  }
  cout << endl;
  return 0;
}
