#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long x;
  set<long long> s;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    s.insert(x);
  }
  bool flag = true;
  set<long long>::reverse_iterator it;
  set<long long>::iterator it1;
  long long ele, ele1;
  while (flag == true) {
    flag = false;
    it = s.rbegin();
    it1 = s.end();
    it1--;
    ele = *it;
    ele1 = ele / 2;
    while (ele1 >= 1) {
      if (s.count(ele1) == 0) {
        s.insert(ele1);
        s.erase(it1);
        flag = true;
        break;
      } else
        ele1 = ele1 / 2;
    }
  }
  for (auto it : s) cout << it << " ";
}
