#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int MN = 1e5 + 5;
int N;
map<int, bool> used;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> N;
  priority_queue<int> q;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    used[a] = true;
    q.push(a);
  }
  while (true) {
    int cur = q.top();
    for (int nxt = cur / 2; nxt >= 0; nxt /= 2) {
      if (nxt == 0) goto out;
      if (!used[nxt]) {
        q.pop();
        used[cur] = false;
        used[nxt] = true;
        q.push(nxt);
        break;
      }
    }
  }
out:;
  while (!q.empty()) {
    cout << q.top() << " ";
    q.pop();
  }
  return 0;
}
