#include <bits/stdc++.h>
using namespace std;
bool Finish_read;
template <class T>
inline void read(T &x) {
  Finish_read = 0;
  x = 0;
  int f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    if (ch == EOF) return;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  x *= f;
  Finish_read = 1;
}
template <class T>
inline void print(T x) {
  if (x / 10 != 0) print(x / 10);
  putchar(x % 10 + '0');
}
template <class T>
inline void writeln(T x) {
  if (x < 0) putchar('-');
  x = abs(x);
  print(x);
  putchar('\n');
}
template <class T>
inline void write(T x) {
  if (x < 0) putchar('-');
  x = abs(x);
  print(x);
}
const int maxn = 5e5;
int n;
int y[maxn];
set<int> s;
bool check(int x) {
  s.clear();
  for (int i = 1; i <= n; i++) {
    int yy = y[i];
    while (yy > x) yy >>= 1;
    while (s.find(yy) != s.end()) {
      yy >>= 1;
      if (!yy) return 0;
    }
    s.insert(yy);
  }
  return 1;
}
int main() {
  read(n);
  for (int i = 1; i <= n; i++) {
    read(y[i]);
  }
  int l = 1, r = 1e9 + 7, res;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(mid)) {
      r = mid - 1;
      res = mid;
    } else
      l = mid + 1;
  }
  s.clear();
  for (int i = 1; i <= n; i++) {
    while (y[i] > res) y[i] >>= 1;
    while (s.find(y[i]) != s.end()) y[i] >>= 1;
    s.insert(y[i]);
    printf("%d ", y[i]);
  }
  puts("");
  return 0;
}
