#include <bits/stdc++.h>
int n;
int sequence[50050];
std::map<int, bool> map;
int main(void) {
  int i, j, k;
  std::map<int, bool>::iterator x;
  scanf("%d", &n);
  for (i = 0; i < n; ++i) scanf("%d", &sequence[i]), map[sequence[i]] = 1;
  x = map.end();
  --x;
  while (true) {
    i = x->first;
    while (i && map[i]) i >>= 1;
    if (!i) break;
    map[i] = true;
    map.erase(x--);
  }
  x = map.end();
  --x;
  while (true) {
    printf("%d ", x->first);
    if (x == map.begin()) break;
    --x;
  }
  puts("");
  return 0;
}
