#include <bits/stdc++.h>
using namespace std;
string toStr(int x) {
  string ans = "";
  while (x) {
    ans.push_back('0' + (x & 1));
    x >>= 1;
  }
  reverse(ans.begin(), ans.end());
  return ans;
}
int borsz = 1;
int n;
int bor[1000000][2];
int kol[1000000], fl[1000000];
void dfs(int v, int num, int r, vector<int>& ans) {
  if (kol[v] == 0) return;
  int oldsz = ans.size();
  int k = 0;
  dfs(bor[v][0], num * 2, r, ans);
  dfs(bor[v][1], num * 2 + 1, r, ans);
  k = ans.size() - oldsz;
  if (k == kol[v]) return;
  if (num <= r) {
    ans.push_back(num);
    return;
  }
  return;
}
vector<int> getAns(int n, int r) {
  vector<int> ans;
  int nn = n;
  dfs(1, 1, r, ans);
  if (ans.size() != n || ans[0] < 0) return vector<int>();
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int a;
    scanf("%d", &a);
    string s = toStr(a);
    int v = 0;
    for (char cc : s) {
      int c = cc - '0';
      if (bor[v][c] == 0) bor[v][c] = borsz++;
      v = bor[v][c];
    }
    kol[v]++;
    fl[v] = 1;
  }
  for (int i = borsz; i > 0; --i) kol[i] += kol[bor[i][0]] + kol[bor[i][1]];
  int l = n - 1;
  int r = 1000000000;
  while (l + 1 < r) {
    int mid = (l + r) / 2;
    vector<int> ans = getAns(n, mid);
    if (ans.empty())
      l = mid;
    else
      r = mid;
  }
  vector<int> ans = getAns(n, r);
  for (int x : ans) cout << x << ' ';
  cout << "\n";
  return 0;
}
