#include <bits/stdc++.h>
using namespace std;
const int MAXN = 50000;
const int MAXLOG = 30;
int q[MAXN * MAXLOG + 10], qcnt, a[MAXN + 10], Fa[MAXN * MAXLOG + 10],
    cnt[MAXN * MAXLOG + 10], n, pre[MAXN * MAXLOG + 10];
bool check(int p) {
  memset(pre, 0, sizeof pre);
  for (int i = p; i >= 1; i--) {
    if (cnt[i] - pre[i] > 0) {
      pre[Fa[i]] += pre[i] + 1;
    } else if (cnt[i] == pre[i])
      pre[Fa[i]] += pre[i];
  }
  return pre[0] >= n;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    int tmp = a[i];
    while (tmp != 1) {
      q[++qcnt] = tmp;
      tmp = tmp >> 1;
    }
  }
  q[++qcnt] = 1;
  sort(q + 1, q + 1 + qcnt);
  qcnt = unique(q + 1, q + 1 + qcnt) - q - 1;
  for (int i = 2; i <= qcnt; i++)
    Fa[i] = lower_bound(q + 1, q + 1 + qcnt, q[i] >> 1) - q;
  for (int i = 1; i <= n; i++) {
    int tmp = lower_bound(q + 1, q + 1 + qcnt, a[i]) - q;
    while (tmp != 1) {
      cnt[tmp]++;
      tmp = Fa[tmp];
    }
    cnt[tmp]++;
  }
  int l = 1, r = qcnt, ans = -1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(mid)) {
      r = mid - 1;
      ans = mid;
    } else
      l = mid + 1;
  }
  memset(pre, 0, sizeof pre);
  vector<int> ansv;
  for (int i = ans; i >= 1; i--) {
    if (cnt[i] > pre[i]) {
      pre[Fa[i]] += pre[i] + 1;
      ansv.push_back(q[i]);
    } else if (pre[i] == cnt[i])
      pre[Fa[i]] += pre[i];
  }
  for (int i = 0; i < n; i++)
    printf("%d%c", ansv[i], i == (n - 1) ? '\n' : ' ');
  return 0;
}
