#include <bits/stdc++.h>
using namespace std;
int n, m, tot;
int a, b, T;
long long K;
typedef struct Ed {
  int a, nxt, c;
} E;
const double pi = 4 * atan(1);
long long mpow(long long x, long long y, long long p) {
  long long res = 1;
  while (y) {
    if (y & 1) res = res * x % p;
    y = y >> 1;
    x = x * x % p;
  }
  return res;
}
long long qpow(long long x, int y) {
  long long res = 1;
  int i = 0;
  while (y) {
    if (y & 1) res = res * x;
    y = y >> 1;
    x = x * x;
  }
  return res;
}
long long gcd(long long x, long long y) {
  while (y) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}
double mabs(double x) {
  if (x < 0) return -x;
  return x;
}
void readline(char *x) {
  int l = 0;
  char c;
  while (scanf("%c", &c) != EOF && c != '\n') x[l++] = c;
  if (l == 0)
    while (scanf("%c", &c) != EOF && c != '\n') x[l++] = c;
  x[l] = 0;
}
set<int> S;
priority_queue<int> h;
int main(void) {
  T = 1;
  for (int ci = 1; ci <= T; ++ci) {
    scanf("%d", &n);
    S.clear();
    while (!h.empty()) h.pop();
    for (int i = 0; i < n; ++i) {
      int x;
      scanf("%d", &x);
      h.push(x);
      S.insert(x);
    }
    while (!h.empty()) {
      int k = h.top(), u = k;
      h.pop();
      while (k && S.count(k)) k >>= 1;
      if (k) {
        S.erase(u);
        S.insert(k);
        h.push(k);
      } else
        break;
    }
    int flag = 1;
    for (set<int>::iterator it = S.begin(); it != S.end(); ++it) {
      if (flag)
        printf("%d", *it);
      else
        printf(" %d", *it);
      flag = 0;
    }
    puts("");
  }
  return 0;
}
