#include <bits/stdc++.h>
using namespace std;
int n, k;
priority_queue<int> q;
map<int, bool> f2;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &k);
    f2[k] = true;
    q.push(k);
  }
  while (true) {
    int temp = q.top() >> 1;
    while (f2[temp] && temp != 1) temp >>= 1;
    if (f2[temp] || q.top() == 1) break;
    q.pop();
    q.push(temp);
    f2[temp] = true;
  }
  while (!q.empty()) {
    printf("%d ", q.top());
    q.pop();
  }
}
