#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const int MAX = 1e5 + 10;
const int MOD = 1000000007;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int n, x;
  vector<int> v;
  map<int, bool> HASH;
  priority_queue<int, vector<int>, less<int>> PQ;
  cin >> n;
  for (__typeof(1) i = 1; i <= n; i++) {
    cin >> x;
    v.push_back(x);
    HASH[x] = true;
    PQ.push(x);
  }
  while (1) {
    int x = PQ.top();
    bool flag = true;
    HASH[x] = false;
    while (x != 1) {
      x /= 2;
      if (HASH.count(x) == 0) {
        HASH[x] = true;
        PQ.push(x);
        flag = false;
        break;
      }
    }
    if (flag) {
      break;
    }
    PQ.pop();
  }
  while (1) {
    cout << PQ.top();
    PQ.pop();
    if (PQ.empty()) {
      cout << '\n';
      break;
    }
    cout << " ";
  }
  return 0;
}
