#include <bits/stdc++.h>
using namespace std;
int N, Y[50001];
set<int> pos[50001];
set<int> used;
priority_queue<int> q;
int next(int x) {
  int temp = x;
  while (x != 0) {
    if (used.count(x) == 0) return x;
    x /= 2;
  }
  return temp;
}
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> Y[i];
    used.insert(Y[i]);
    q.push(Y[i]);
  }
  for (;;) {
    int num = next(q.top());
    if (q.top() == num) break;
    used.erase(num);
    used.insert(num);
    q.pop();
    q.push(num);
  }
  while (!q.empty()) {
    cout << q.top() << ' ';
    q.pop();
  }
  cout << endl;
  return 0;
}
