#include <bits/stdc++.h>
using namespace std;
long long getint() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return f * x;
}
int gd() {
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  return ch - '0';
}
long long n;
int a[112345];
bool b[112345];
int c[112345];
int pre[112345];
long long sum[112345];
long long mx = 0;
int find(int x) {
  int res = x;
  while (pre[res] != res) res = pre[res];
  int t;
  while (pre[x] != res) {
    t = pre[x];
    pre[x] = res;
    x = t;
  }
  return res;
}
void un(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  pre[x] = y;
  sum[y] += sum[x];
}
map<int, int> mp;
bool check(int m) {
  if (m == 0) return false;
  mp.clear();
  for (int i = 1; i <= n; i++) {
    int x = a[i];
    for (int j = 0;; j++) {
      int y = x >> j;
      if (!y) return false;
      if (y > m || mp[y]) continue;
      mp[y] = 1;
      break;
    }
  }
  return true;
}
int ans[112345];
int gett(int m) {
  mp.clear();
  for (int i = 1; i <= n; i++) {
    int x = a[i];
    for (int j = 0;; j++) {
      int y = x >> j;
      if (y > m || mp[y]) continue;
      mp[y] = 1;
      ans[i] = y;
      break;
    }
  }
  return true;
}
int main() {
  n = getint();
  int l = 0, r = 0;
  for (int i = 1; i <= n; i++) a[i] = getint(), r = max(r, a[i]);
  while (l + 1 < r) {
    int mid = (l + r) >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid;
  }
  gett(r);
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
}
