#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int a[n];
  vector<int> v[n];
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n, greater<int>());
  for (int i = 0; i < n; ++i) {
    int no = a[i];
    while (no) {
      v[i].push_back(no);
      no >>= 1;
    }
  }
  int s = n, e = 1e9, m, ans;
  set<int> t;
  while (s <= e) {
    m = (s + e) / 2;
    t.clear();
    for (int i = 0; i < n; ++i)
      for (auto it : v[i])
        if (it <= m && !t.count(it)) {
          t.insert(it);
          break;
        }
    if (t.size() == n)
      ans = m, e = m - 1;
    else
      s = m + 1;
  }
  t.clear();
  for (int i = 0; i < n; ++i)
    for (auto it : v[i])
      if (it <= ans && !t.count(it)) {
        t.insert(it);
        cout << it << " ";
        break;
      }
}
