#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const double eps = 1e-8;
const long long linf = 1e18;
const int MAXN = 5e4 + 10;
set<int> st, res;
int a[MAXN], temp[MAXN];
bool judge(int mid, int n) {
  st.clear();
  memcpy(temp, a, sizeof(a));
  for (int i = 0; i < n; ++i) {
    while (temp[i] > mid || st.count(temp[i])) {
      temp[i] >>= 1;
      if (temp[i] == 0) return 0;
    }
    st.insert(temp[i]);
  }
  return 1;
}
int main() {
  int n;
  scanf("%d", &n);
  int maxn = 0;
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]), maxn = max(maxn, a[i]);
  int l = 1, r = maxn;
  while (r >= l) {
    int mid = l + r >> 1;
    if (judge(mid, n)) {
      res = st;
      r = mid - 1;
    } else
      l = mid + 1;
  }
  set<int>::iterator it = res.begin();
  printf("%d", (*it));
  ++it;
  for (; it != res.end(); ++it) printf(" %d", (*it));
  puts("");
  return 0;
}
