#include <bits/stdc++.h>
using namespace std;
map<long long int, long long int> vis;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  long long int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  set<long long int> s;
  for (int i = 0; i < n; i++) {
    s.insert(a[i]);
    vis[a[i]] = 1;
  }
  int flag = 1;
  while (flag) {
    int count = 0;
    long long int no;
    set<long long int>::iterator it = s.end();
    it--;
    no = *it;
    long long int num = no;
    while (num >= 1) {
      if (vis[num] == 0) {
        s.erase(no);
        s.insert(num);
        vis[num] = 1;
        break;
      } else
        num /= 2;
    }
    if (num == 0) break;
  }
  for (set<long long int>::iterator it = s.begin(); it != s.end(); ++it)
    cout << *it << " ";
  return 0;
}
