#include <bits/stdc++.h>
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
const int MAXN = 50050;
int Y[MAXN];
int X[MAXN];
int N;
bool ok(int x) {
  set<int> S;
  for (int i = 0; i < N; i++) {
    int y = Y[i];
    while (y > x) y /= 2;
    while (1) {
      if (S.find(y) == S.end()) break;
      y /= 2;
    }
    if (y == 0) return false;
    S.insert(y);
    X[i] = y;
  }
  return true;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  for (int i = 0; i < N; i++) cin >> Y[i];
  int low = 0, high = 1e9;
  while (high - low > 1) {
    const int med = (low + high) / 2;
    if (ok(med))
      high = med;
    else
      low = med;
  }
  assert(ok(high));
  for (int i = 0; i < N; i++) cout << X[i] << " ";
  cout << endl;
  return 0;
}
