#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k;
  cin >> n;
  set<int> y;
  set<int>::iterator itr;
  for (int i = 0; i < n; i++) {
    cin >> k;
    y.insert(k);
  }
  k = 1;
  while (true) {
    itr = y.end();
    itr--;
    int temp = *itr;
    int prev = temp;
    while (prev / 2 > 0) {
      if (y.find(prev / 2) == y.end()) {
        y.insert(prev / 2);
        y.erase(temp);
        temp = -1;
        break;
      } else {
        prev = prev / 2;
      }
    }
    if (temp != -1) break;
  }
  for (itr = y.begin(); itr != y.end(); itr++) cout << *itr << " ";
  cout << endl;
}
