#include <bits/stdc++.h>
using namespace std;
set<int> s;
priority_queue<int> q;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    s.insert(-a);
    q.push(a);
  }
  bool otg = true;
  while (otg) {
    int curr = (q.top());
    otg = false;
    curr /= 2;
    while (curr != 0 and !otg) {
      if (s.find(-curr) == s.end()) {
        otg = true;
        s.erase(-q.top());
        s.insert(-curr);
        q.pop();
        q.push(curr);
      }
      curr /= 2;
    }
  }
  for (set<int>::iterator it = s.begin(); it != s.end(); it++) {
    cout << -(*it) << " ";
  }
  cout << "\n";
  return 0;
}
