#include <bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main() {
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  long long start = 1, finish = 1000000000000, mid;
  do {
    mid = (start + finish) / 2;
    vector<long long> vi;
    set<long long> si;
    for (long long i = 0; i < n; i++) {
      long long u = arr[i];
      vector<long long> hi;
      while (u) {
        hi.push_back(u);
        u /= 2;
      }
      for (long long j = 0; j < hi.size(); j++) {
        if (si.find(hi[j]) == si.end() && hi[j] <= mid) {
          vi.push_back(hi[j]);
          si.insert(hi[j]);
          break;
        }
      }
    }
    if (vi.size() == n)
      finish = mid - 1;
    else
      start = mid + 1;
  } while (start <= finish);
  for (long long i = mid - 1; i <= mid + 1; i++) {
    vector<long long> vi;
    set<long long> si;
    for (long long j = 0; j < n; j++) {
      long long u = arr[j];
      vector<long long> hi;
      while (u) {
        hi.push_back(u);
        u /= 2;
      }
      for (long long l = 0; l < hi.size(); l++) {
        if (si.find(hi[l]) == si.end() && hi[l] <= i) {
          vi.push_back(hi[l]);
          si.insert(hi[l]);
          break;
        }
      }
    }
    if (vi.size() == n) {
      for (long long j = 0; j < n; j++) cout << vi[j] << " ";
      return 0;
    }
  }
  return 0;
}
