#include <bits/stdc++.h>
using namespace std;
const int MaxN = 5e4;
priority_queue<int> q;
int n, cont, Max;
int num[MaxN + 5];
map<int, int> vis;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &num[i]);
    q.push(num[i]);
    vis[num[i]] = true;
  }
  sort(num + 1, num + 1 + n);
  while (true) {
    int temp = q.top();
    int t = temp;
    while (vis[temp] && temp != 0) {
      temp /= 2;
    }
    if (temp == 0) break;
    q.pop();
    vis[temp] = true;
    vis[t] = false;
    q.push(temp);
  }
  while (q.size()) {
    printf("%d ", q.top());
    q.pop();
  }
  printf("\n");
}
