#include <bits/stdc++.h>
using namespace std;
int n;
int y[50010] = {};
int t[50010] = {};
unordered_map<int, int> ha;
bool cmp(int x, int y) { return x > y; }
bool ff(int x) {
  ha.clear();
  int tmp;
  for (int i = 1; i <= n; i++) {
    int tmp = t[i];
    while (tmp > x || ha.find(tmp) != ha.end()) tmp >>= 1;
    if (!tmp) return 0;
    ha[tmp] = 1;
  }
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &t[i]);
  sort(t + 1, t + n + 1, cmp);
  int l = 1;
  int r = t[1];
  while (l < r) {
    int mid = (l + r) / 2;
    if (ff(mid))
      r = mid;
    else
      l = mid + 1;
  }
  ff(l);
  for (auto it = ha.begin(); it != ha.end(); it++) {
    printf("%d ", it->first);
  }
  return 0;
}
