#include <bits/stdc++.h>
using namespace std;
void zanj0() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
vector<long long int> getBin(long long int x) {
  vector<long long int> ret;
  while (x) {
    ret.push_back(x & 1);
    x >>= 1;
  }
  reverse(ret.begin(), ret.end());
  return ret;
}
void out(vector<long long int> v) {
  for (long long int i : v) {
    cout << i << " ";
  }
  cout << "\n";
}
const long long int N = 5e4 + 5;
long long int ret[N];
long long int a[N];
long long int n;
bool ok(long long int x) {
  set<long long int> s;
  for (long long int i = 0; i < n; i++) {
    long long int val = a[i];
    while (val > x) val >>= 1;
    while (val && s.count(val)) val >>= 1;
    if (val == 0) return false;
    s.insert(val);
    ret[i] = val;
  }
  return true;
}
void solve() {
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  long long int low = 1;
  long long int high = 1e9;
  long long int poss = 1e18;
  while (low <= high) {
    long long int mid = low + (high - low) / 2;
    if (ok(mid)) {
      poss = mid;
      high = mid - 1;
    } else
      low = mid + 1;
  }
  ok(poss);
  for (long long int i = 0; i < n; i++) {
    cout << ret[i] << " ";
  }
  cout << "\n";
}
int32_t main() {
  zanj0();
  solve();
  cerr << "Time : " << 1000 * (long double)clock() / (long double)CLOCKS_PER_SEC
       << "ms\n";
  return 0;
}
