#include <bits/stdc++.h>
using namespace std;
ifstream fi("input.inp");
set<int> s;
int main() {
  ios::sync_with_stdio(0);
  int n, x;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> x;
    s.insert(x);
  }
  while (1) {
    auto x = s.end();
    --x;
    int y = *x;
    while (y > 0 && s.count(y) > 0) y /= 2;
    if (y == 0) break;
    s.erase(x);
    s.insert(y);
  }
  for (auto i : s) cout << i << ' ';
  return 0;
}
