#include <bits/stdc++.h>
using namespace std;
int n, x;
set<int> used;
priority_queue<int> pq;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    used.insert(x);
    pq.push(x);
  }
  while (!pq.empty()) {
    x = pq.top();
    int y = x;
    while (used.find(y) != used.end()) {
      y /= 2;
    }
    if (y == 0) break;
    used.erase(x);
    used.insert(y);
    pq.pop();
    pq.push(y);
  }
  while (!pq.empty()) {
    cout << pq.top() << ' ';
    pq.pop();
  }
}
