#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  set<long long> s;
  for (long long i = 0; i < n; i++) s.insert(a[i]);
  long long flag = 1;
  while (flag) {
    flag = 0;
    set<long long>::iterator it = s.end();
    it--;
    long long k = *it;
    long long kk = k / 2;
    s.erase(it);
    while (kk != 0) {
      if (s.find(kk) == s.end()) {
        flag = 1;
        s.insert(kk);
        break;
      }
      kk = kk / 2;
    }
    if (flag == 0) s.insert(k);
  }
  for (set<long long>::iterator it = s.begin(); it != s.end(); it++)
    cout << *it << " ";
  return 0;
}
