#include <bits/stdc++.h>
using namespace std;
int n, x;
set<int, greater<int> > s;
inline void get_ready() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); i++) {
    scanf("%d", &x);
    s.insert(x);
  }
}
inline void solve() {
  while (1) {
    int now = *s.begin(), x = now;
    while (x && s.count(x)) x /= 2;
    if (x)
      s.erase(s.begin()), s.insert(x);
    else
      break;
  }
  set<int, greater<int> >::iterator y;
  for (y = s.begin(); y != s.end(); y++) printf("%d ", *y);
}
int main() {
  get_ready();
  solve();
  return 0;
}
