#include <bits/stdc++.h>
std::set<int> S;
int n;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int t;
    scanf("%d", &t);
    S.insert(t);
  }
  while (1) {
    int a = *S.rbegin();
    int t = a;
    do {
      t >>= 1;
    } while (S.find(t) != S.end());
    if (t == 0) break;
    S.erase(a);
    S.insert(t);
  }
  for (std::set<int>::iterator it = S.begin(); it != S.end(); ++it) {
    printf("%d ", *it);
  }
  return 0;
}
