#include <bits/stdc++.h>
using namespace std;
long long cnt, arr[111111];
vector<long long> v[61111], skupaj;
map<long long, long long> m;
long long n;
vector<long long> rez;
void razcep(long long x) {
  long long tren = arr[x];
  v[x].push_back((1LL << 40));
  while (tren > 1) {
    v[x].push_back(tren);
    tren /= 2;
  }
  v[x].push_back(1);
  skupaj.push_back(1);
  reverse(v[x].begin(), v[x].end());
}
bool check(long long mid) {
  rez.clear();
  m.clear();
  for (long long i = 0; i < n; i++) {
    long long pos;
    pos = upper_bound(v[i].begin(), v[i].end(), mid) - v[i].begin() - 1;
    while (pos >= 0 && m[v[i][pos]] == 1) pos--;
    if (pos < 0) return 0;
    rez.push_back(v[i][pos]);
    m[v[i][pos]] = 1;
  }
  return 1;
}
int main() {
  cnt = 0;
  scanf("%lld", &n);
  for (long long i = 0; i < n; i++) scanf("%lld", arr + i);
  sort(arr, arr + n);
  for (long long i = 0; i < n; i++) razcep(i);
  sort(skupaj.begin(), skupaj.end());
  long long l = 0, d = (1LL << 31), mid, ans = -1;
  while (l <= d) {
    mid = (l + d) / 2;
    if (check(mid)) {
      d = mid - 1;
      ans = mid;
    } else
      l = mid + 1;
  }
  check(ans);
  for (long long i = 0; i < n; i++) cout << rez[i] << " ";
  return 0;
}
