#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int n, m, x, y;
int a[maxn];
set<int> s;
int ans[maxn], cnt;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    s.insert(a[i]);
  }
  while (1) {
    set<int>::iterator it = s.end();
    it--;
    int p = *it;
    while (s.find(p) != s.end() && p) {
      p >>= 1;
    }
    if (p == 0) break;
    s.erase(it);
    s.insert(p);
  }
  int first = 0;
  for (set<int>::iterator it = s.begin(); it != s.end(); it++) {
    if (!first) {
      first = 1;
      printf("%d", *it);
    } else
      printf(" %d", *it);
  }
  return 0;
}
