#include <bits/stdc++.h>
using namespace std;
const long long M = 1e7 + 9;
const long long inf = 1e19;
const int si = 1e5 + 9;
int n, x;
set<int> st;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &x), st.insert(x);
  bool ok = 1;
  while (ok) {
    int val = *(st.rbegin());
    int one = val;
    while (val > 0) {
      if (st.count(val) == 0) {
        break;
      }
      val >>= 1;
    }
    if (!val) break;
    st.erase(st.find(one));
    st.insert(val);
  }
  for (auto x : st) {
    cout << (x) << ' ';
  }
  return 0;
  ;
}
