#include <bits/stdc++.h>
using namespace std;
const int maxn = 50000 + 5;
int a[maxn];
priority_queue<int> q;
map<int, int> mp;
int y[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    q.push(a[i]);
    mp[a[i]] = 1;
  }
  while (!q.empty()) {
    int tmp1 = q.top();
    int tmp2 = tmp1;
    while (mp[tmp1] == 1 && tmp1 != 0) {
      tmp1 /= 2;
    }
    if (tmp1 == 0) break;
    mp[tmp2] = 0;
    mp[tmp1] = 1;
    q.pop();
    q.push(tmp1);
  }
  while (!q.empty()) {
    cout << q.top() << " ";
    q.pop();
  }
  return 0;
}
