#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  set<int> q;
  cin >> n;
  while (n--) scanf("%d", &x), q.insert(x);
  for (;;) {
    x = *(--q.end());
    while (q.count(x /= 2))
      ;
    if (x == 0) break;
    q.erase(--q.end());
    q.insert(x);
  }
  for (set<int>::iterator it = q.begin(); it != q.end(); it++) {
    printf("%d ", *it);
  }
}
