#include <bits/stdc++.h>
using namespace std;
int n;
priority_queue<int> pq;
set<int> elem;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int y;
    cin >> y;
    pq.push(y);
    elem.insert(y);
  }
  while (true) {
    int maxval = pq.top();
    elem.erase(elem.find(maxval));
    while (elem.count(maxval >>= 1))
      ;
    if (!maxval) break;
    pq.pop();
    pq.push(maxval);
    elem.insert(maxval);
  }
  while (!pq.empty()) {
    cout << pq.top() << " ";
    pq.pop();
  }
  return 0;
}
