#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 5e4 + 3;
int n;
int a[MAX_N];
set<int> ST;
priority_queue<int> PQ;
int findMin(int x) {
  int num = x / 2;
  while (num > 0) {
    if (!ST.count(num)) return num;
    num /= 2;
  }
  return -1;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    ST.insert(a[i]);
    PQ.push(a[i]);
  }
  while (true) {
    int top = PQ.top();
    int val = findMin(top);
    if (val == -1)
      break;
    else {
      ST.erase(top);
      ST.insert(val);
      PQ.pop();
      PQ.push(val);
    }
  }
  set<int>::iterator it = ST.begin();
  for (int i = 0; i < n; ++i) {
    printf("%d%c", *it, " \n"[i == n - 1]);
    ++it;
  }
  return 0;
}
