#include <bits/stdc++.h>
const int N = 5e4 + 100;
int n;
int a[N];
std::vector<int> edge[N];
std::vector<int> all;
int visit[N * 50], timeClock;
int left[N * 50];
void init() {
  std::cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
}
void discretize() {
  all.clear();
  for (int i = 1; i <= n; i++) {
    int t = a[i];
    while (t) {
      all.push_back(t);
      t >>= 1;
    }
  }
  std::sort(all.begin(), all.end());
  all.erase(std::unique(all.begin(), all.end()), all.end());
}
void addEdge() {
  for (int i = 1; i <= n; i++) {
    int t = a[i];
    while (t) {
      int r = std::lower_bound(all.begin(), all.end(), t) - all.begin() + 1;
      edge[i].push_back(r);
      t >>= 1;
    }
    std::sort(edge[i].begin(), edge[i].end());
  }
}
bool match(int u, int mid) {
  for (int i = 0; i < (int)edge[u].size() && edge[u][i] <= mid; i++) {
    int v = edge[u][i];
    if (visit[v] == timeClock) {
      continue;
    }
    visit[v] = timeClock;
    if (left[v] == 0 || match(left[v], mid)) {
      left[v] = u;
      return true;
    }
  }
  return false;
}
bool check(int mid) {
  for (int i = 1; i <= mid; i++) {
    left[i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    timeClock++;
    if (match(i, mid) == false) {
      return false;
    }
  }
  return true;
}
void work() {
  discretize();
  addEdge();
  int low = n, high = (int)all.size();
  int answer = -1;
  while (low <= high) {
    int mid = (low + high) >> 1;
    if (check(mid)) {
      answer = mid;
      high = mid - 1;
    } else {
      low = mid + 1;
    }
  }
  check(answer);
  static int x[N];
  for (int i = 1; i <= answer; i++) {
    x[left[i]] = all[i - 1];
  }
  for (int i = 1; i <= n; i++) {
    printf("%d%c", x[i], " \n"[i == n]);
  }
}
int main() {
  init();
  work();
  return 0;
}
