#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, n;
  set<int> A;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    A.insert(x);
  }
  while (true) {
    int w = *A.rbegin();
    int z = -1;
    for (int s = w / 2; s != 0; s /= 2) {
      if (!A.count(s)) {
        z = s;
        break;
      }
    }
    if (z == -1) {
      break;
    }
    A.erase(w);
    A.insert(z);
  }
  for (auto q = A.begin(); q != A.end(); q++) cout << *q << " ";
  cout << endl;
  return 0;
}
