#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool upmin(T &x, T y) {
  return y < x ? x = y, 1 : 0;
}
template <typename T>
inline bool upmax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
const long double eps = 1e-11;
const long double pi = acos(-1);
const long long oo = 1 << 30;
const long long loo = 1ll << 62;
const long long mods = 998244353;
const long long MAXN = 200005;
const long long INF = 0x3f3f3f3f;
inline long long read() {
  long long f = 1, x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  return x * f;
}
set<long long> Set, Ans;
map<long long, long long> Map;
long long a[MAXN];
signed main() {
  long long n = read();
  for (long long i = 1, x; i <= n; i++) x = read(), Map[x] = 1, Set.insert(x);
  Map[0] = 1;
  while (1) {
    long long t = *Set.rbegin(), flag = 0;
    Map[t] = 0;
    for (t = t >>= 1; t; t >>= 1)
      if (!Map[t]) {
        flag = 1, Map[t] = 1, Set.erase(--Set.end()), Set.insert(t);
        break;
      }
    if (!flag) break;
  }
  for (auto v : Set) printf("%d ", v);
  return 0;
}
