#include <bits/stdc++.h>
using namespace std;
const int N = 1e7 + 10;
int n, m, now;
int a[50005];
map<int, int> use;
int check(int lim) {
  for (int i = 1; i <= n; ++i) {
    int x = a[i];
    while (x > lim) x >>= 1;
    while (use[x] == now) x >>= 1;
    if (!x) return 0;
    use[x] = now;
  }
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  int l = n, r = 1e9;
  while (l < r) {
    ++now;
    int mid = (l + r) >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  ++now;
  for (int i = 1; i <= n; ++i) {
    int x = a[i];
    while (x > l) x >>= 1;
    while (use[x] == now) x >>= 1;
    printf("%d ", x);
    use[x] = now;
  }
  puts("");
  return 0;
}
