#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(time(0));
const long long inf = 0x3f3f3f3f3f3f3f3fLL;
const long long N = 3e5 + 10;
const long long MOD = 1e9 + 7;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, x;
  cin >> n;
  set<long long, greater<long long>> s;
  for (long long i = 0; i < n; i++) {
    cin >> x, s.insert(x);
  }
  bool f = true;
  while (f) {
    f = false;
    long long cur = *s.begin();
    while (cur > 1) {
      cur /= 2;
      if (!s.count(cur)) {
        s.erase(s.begin());
        s.insert(cur);
        f = true;
        break;
      }
    }
  }
  for (auto i : s) cout << i << ' ';
  return 0;
}
