#include <bits/stdc++.h>
using namespace std;
const int maxn = 50005;
set<int> ans;
int n;
int a[maxn];
bool check(int m) {
  ans.clear();
  for (int j = n - 1; j >= 0; j--) {
    int x = a[j];
    while (x > m) x /= 2;
    while (x > 0 && ans.find(x) != ans.end()) {
      x /= 2;
    }
    if (x == 0) return false;
    ans.insert(x);
  }
  return true;
}
int main() {
  scanf("%d", &n);
  for (int j = 0; j < (int)n; j++) scanf("%d", &a[j]);
  sort(a, a + n);
  int s = 1;
  int f = 1e9;
  while (s < f) {
    int m = (s + f) / 2;
    if (check(m)) {
      f = m;
    } else
      s = m + 1;
  }
  check(s);
  for (int x : ans) printf("%d ", x);
}
