#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1.0);
const long double eps = 1e-9;
const int INF = 1E9;
const int MAXN = 100500 * 32;
int n;
int a[MAXN], pos[MAXN];
int root, sz;
int nxt[MAXN][2], par[MAXN], mark[MAXN], num[MAXN];
vector<int> b;
set<pair<int, int> > lib;
int main() {
  cin >> n;
  for (int i = 0; i < (int)(n); i++) scanf("%d", &a[i]);
  memset(nxt, -1, sizeof(nxt));
  memset(mark, 0, sizeof(mark));
  root = 0;
  num[root] = 1;
  par[root] = -1;
  sz = 1;
  for (int i = 0; i < n; i++) {
    int x = a[i];
    b.clear();
    while (x > 0) {
      b.push_back(x & 1);
      x >>= 1;
    }
    b.pop_back();
    reverse((b).begin(), (b).end());
    int v = root;
    int curNum = num[v];
    for (auto bit : b) {
      curNum = curNum * 2 + bit;
      if (nxt[v][bit] == -1) {
        nxt[v][bit] = sz;
        par[sz] = v;
        num[sz] = curNum;
        sz++;
      }
      v = nxt[v][bit];
    }
    mark[v] = 1;
    pos[i] = v;
  }
  for (int i = 0; i < (int)(n); i++) lib.insert({-a[i], i});
  while (true) {
    auto elem = *lib.begin();
    lib.erase(elem);
    int i = elem.second;
    int x = a[i];
    int v = pos[i];
    while (v != -1 && mark[v]) {
      v = par[v];
    }
    if (v == -1) break;
    mark[v] = 1;
    mark[pos[i]] = 0;
    a[i] = num[v];
    pos[i] = v;
    lib.insert({-a[i], i});
  }
  sort(a, a + n);
  for (int i = 0; i < (int)(n); i++) printf("%d ", a[i]);
  return 0;
}
