#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int N = 1000002;
const double PI = 4 * atan(1);
const double eps = 1e-7;
const long long oo = 1e18;
long long n;
long long a[N];
long long b[N];
unordered_map<long long, long long> maa;
bool ok(long long u) {
  maa.clear();
  for (int i = 0; i < n; i++) {
    b[i] = a[i];
    maa[b[i]]++;
  }
  for (int i = 0; i < n; i++) {
    if (b[i] > u) {
      while ((b[i] > u || maa[b[i]]) && b[i] > 0) {
        b[i] /= 2;
      }
    }
    if (b[i] == 0) return 0;
    maa[a[i]]--;
    maa[b[i]]++;
  }
  return 1;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  reverse(a, a + n);
  long long l = n;
  long long r = a[0];
  while (l < r - 1) {
    long long mid = (l + r) >> 1;
    if (ok(mid)) {
      r = mid;
    } else {
      l = mid;
    }
  }
  if (ok(l)) {
    for (int i = 0; i < n; i++) {
      cout << b[i] << " ";
    }
  } else {
    bool cond = ok(r);
    for (int i = 0; i < n; i++) {
      cout << b[i] << " ";
    }
  }
  return 0;
}
