#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();
  for (int i = 1; i <= n; i++) y[i] = t[i];
  for (int i = 1; i <= n; i++) {
    if (y[i] <= x && ha[y[i]] == 0) {
      ha[y[i]] = 1;
    } else {
      while (1) {
        if (y[i] == 1) {
          return 0;
        }
        if (ha.find(y[i] / 2) == ha.end() && (y[i] / 2) <= x) {
          ha[y[i] / 2] = 1;
          break;
        } else
          y[i] = y[i] / 2;
      }
    }
  }
  return 1;
}
void ans(int x) {
  ha.clear();
  for (int i = 1; i <= n; i++) y[i] = t[i];
  for (int i = 1; i <= n; i++) {
    if (y[i] <= x && ha[y[i]] == 0) {
      ha[y[i]] = 1;
      printf("%d ", y[i]);
    } else {
      while (1) {
        if (ha.find(y[i] / 2) == ha.end() && (y[i] / 2) <= x) {
          ha[y[i] / 2] = 1;
          break;
        } else
          y[i] = y[i] / 2;
      }
      printf("%d ", y[i] / 2);
    }
  }
}
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 = 1000000000;
  while (l < r) {
    int mid = (l + r) / 2;
    if (ff(mid))
      r = mid;
    else
      l = mid + 1;
  }
  ans(l);
  return 0;
}
