#include <bits/stdc++.h>
using namespace std;
const long long int N = 5e4 + 5, mod = 1e9 + 7, bit = 60;
long long int a[N], b[N], n;
vector<long long int> adj[N], v;
bool check(long long int bound) {
  map<long long int, bool> mp;
  for (long long int i = 1; i <= n; i++) {
    bool pos = 0;
    for (auto u : adj[i]) {
      if (u <= bound and mp.find(u) == mp.end()) {
        mp[u] = 1;
        pos = 1;
        b[i] = u;
        break;
      }
    }
    if (!pos) {
      return 0;
    }
  }
  return 1;
}
signed main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long int i;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i + 1];
  }
  sort(a + 1, a + n + 1, greater<long long int>());
  for (i = 1; i <= n; i++) {
    long long int x = a[i];
    while (x > 0) {
      adj[i].push_back(x);
      v.push_back(x);
      x >>= 1;
    }
  }
  sort(v.begin(), v.end());
  long long int l = 0;
  long long int r = v.size() - 1;
  long long int ans;
  while (l <= r) {
    long long int mid = (l + r) >> 1;
    long long int x = v[mid];
    if (check(x)) {
      r = mid - 1;
      ans = x;
    } else {
      l = mid + 1;
    }
  }
  check(ans);
  for (i = 1; i <= n; i++) {
    cout << b[i] << ' ';
  }
  cout << '\n';
  return 0;
}
