#include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(const T &a) {
  return a * a;
}
int n, a[100000];
set<int> used;
map<int, int> Max;
void upd(int x) { Max[x] = max(Max[2 * x], Max[2 * x + 1]); }
int main() {
  scanf("%d", &n);
  int ans = 0;
  for (int i = 0; i < (n); i++) {
    scanf("%d", &a[i]);
    used.insert(a[i]);
    Max[a[i]] = a[i];
    int x = a[i];
    while (x) Max[x] = max(Max[x], a[i]), x /= 2;
  }
  auto it = --used.end();
  while (1) {
    int x = *(--used.end());
    vector<int> p;
    while (x > 1 && used.count(x / 2)) {
      p.push_back(x % 2);
      x /= 2;
    }
    if (x == 1) break;
    p.push_back(x % 2), x /= 2;
    reverse((p).begin(), (p).end());
    for (int i : p) {
      used.insert(x);
      x = x * 2 + i;
      used.erase(x);
    }
  }
  for (int x : used) printf("%d ", x);
  puts("");
}
