#include <bits/stdc++.h>
using namespace std;
const int TAM = 55555;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int n, val, nval;
  cin >> n;
  set<int> exists;
  priority_queue<int> Q;
  for (int i = 0; i < n; i++) {
    cin >> val;
    exists.insert(val);
    Q.push(val);
  }
  while (true) {
    val = Q.top();
    Q.pop();
    nval = val;
    while (exists.find(nval) != exists.end()) nval /= 2;
    if (nval == 0) {
      Q.push(val);
      break;
    }
    exists.erase(exists.find(val));
    Q.push(nval);
    exists.insert(nval);
  }
  while (!Q.empty()) {
    cout << Q.top() << ' ';
    Q.pop();
  }
  return 0;
}
