#include <bits/stdc++.h>
using namespace std;
ifstream input;
ofstream output;
int main(int argc, char *argv[]) {
  input.sync_with_stdio(false);
  output.sync_with_stdio(false);
  int n, tmp, tmp2;
  priority_queue<int> y;
  set<int> used;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    y.push(tmp);
    used.insert(tmp);
  }
  while (1) {
    tmp = y.top();
    tmp2 = tmp;
    y.pop();
    while (tmp > 1) {
      if (used.find(tmp / 2) == used.end()) {
        used.insert(tmp / 2);
        used.erase(tmp2);
        y.push(tmp / 2);
        break;
      }
      tmp /= 2;
    }
    if (tmp == 1) {
      y.push(tmp2);
      break;
    }
  }
  while (y.size()) {
    cout << y.top() << " ";
    y.pop();
  }
  return 0;
}
