#include <bits/stdc++.h>
using namespace std;
void rf() {}
const int nx[8] = {2, -2, -2, 2, 1, 1, -1, -1};
const int ny[8] = {1, 1, -1, -1, 2, -2, -2, 2};
const int Nx[4] = {0, 0, -1, 1};
const int Ny[4] = {1, -1, 0, 0};
const long long LINF = (long long)5e18;
const int INF = 1e9 + 7;
const int N = 6e5 + 1;
const int MAXN = 1e6 + 50;
const double EPS = 1e-9, PI = 3.14159265359;
inline int get_int() {
  char x = getchar();
  int ret = 0;
  bool neg = 0;
  while (!('0' <= x && x <= '9')) {
    if (x == '-') neg = 1;
    x = getchar();
  }
  while ('0' <= x && x <= '9') {
    ret = ret * 10 + x - '0';
    x = getchar();
  }
  if (neg) ret *= -1;
  return ret;
}
int n;
int x[N], y[N];
map<int, int> cnt;
bool ok(int mx) {
  cnt.clear();
  for (int i = 1; i <= n; i++) {
    x[i] = y[i];
  }
  for (int i = 1; i <= n; i++) {
    while (x[i] > mx) x[i] /= 2;
    cnt[x[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    if (cnt[x[i]] > 1) {
      cnt[x[i]]--;
      x[i] /= 2;
      while (cnt[x[i]] > 0 && x[i] > 0) {
        x[i] /= 2;
      }
      if (x[i] == 0) return false;
      cnt[x[i]]++;
    }
  }
  return true;
}
int main() {
  srand(time(0));
  rf();
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &y[i]);
  sort(y + 1, y + n + 1);
  int l = 1, r = INF;
  int ans = -1;
  while (l <= r) {
    int m = (l + r) / 2;
    if (ok(m)) {
      r = m - 1;
      ans = m;
    } else {
      l = m + 1;
    }
  }
  ok(ans);
  for (int i = 1; i <= n; i++) {
    printf("%d ", x[i]);
  }
  return 0;
}
