#include <bits/stdc++.h>
using namespace std;
const int maxm = 100005;
int a[maxm];
set<int> s;
set<int>::iterator it;
int main() {
  int n, i, j, k, sum;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    s.insert(a[i]);
  }
  while (1) {
    it = s.end();
    it--;
    int now = *it;
    while (s.find(now) != s.end() && now) now /= 2;
    if (now == 0) break;
    s.erase(it);
    s.insert(now);
  }
  for (it = s.begin(); it != s.end(); it++) printf("%d ", *it);
  printf("\n");
  return 0;
}
