#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
priority_queue<int> q;
int n, a[50005];
map<int, int> mp;
int dq, num;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i) q.push(a[i]);
  for (int i = 1; i <= n; ++i) mp[a[i]] = 1;
  while (true) {
    dq = q.top();
    q.pop();
    num = 0;
    mp[dq]--;
    while (dq != 0) {
      ++num;
      a[num] = dq;
      dq /= 2;
    }
    bool flag = false;
    for (int i = 2; i <= num; ++i) {
      if (mp[a[i]] == 0) {
        flag = true;
        q.push(a[i]);
        mp[a[i]]++;
        break;
      }
    }
    if (!flag) {
      q.push(a[1]);
      break;
    }
  }
  while (!q.empty()) {
    dq = q.top();
    printf("%d ", dq);
    q.pop();
  }
  return 0;
}
