#include <bits/stdc++.h>
using namespace std;
const int MAX = 100005;
const int MOD = 1000000007;
int n;
vector<int> bins[MAX];
int a[MAX];
int val[MAX];
bool can(int x) {
  unordered_map<int, bool> taken;
  for (int i = 0; i < n; i++) {
    bool took = false;
    int ind =
        upper_bound(bins[i].begin(), bins[i].end(), x) - bins[i].begin() - 1;
    for (int j = ind; ~j; j--) {
      int cur = bins[i][j];
      if (cur <= x && !taken[cur]) {
        taken[cur] = true;
        took = true;
        val[i] = cur;
        break;
      }
    }
    if (!took) {
      return false;
    }
  }
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    int st = a[i];
    while (st > 0) {
      bins[i].push_back(st);
      st /= 2;
    }
    reverse(bins[i].begin(), bins[i].end());
  }
  int lo = 1;
  int hi = 1000000000;
  while (lo < hi) {
    int mid = (lo + hi) / 2;
    if (can(mid)) {
      hi = mid;
    } else {
      lo = mid + 1;
    }
  }
  can(lo);
  for (int i = 0; i < n; i++) {
    printf("%d ", val[i]);
  }
}
