#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
set<int> y;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int c_y;
    scanf("%d", &c_y);
    y.insert(c_y);
  }
  while (true) {
    int c_y = *y.rbegin();
    while (c_y != 0 && y.count(c_y)) {
      c_y /= 2;
    }
    if (c_y == 0) {
      break;
    }
    auto it = y.end();
    y.erase(--it);
    y.insert(c_y);
  }
  for (int c_y : y) {
    printf("%d ", c_y);
  }
  cout << endl;
  return 0;
}
