#include <bits/stdc++.h>
using namespace std;
int arr[50100];
int tmp[50100];
int ans[50100];
map<int, bool> vis;
int n;
bool Check(int mid) {
  vis.clear();
  for (int i = 1; i <= n; ++i) {
    tmp[i] = arr[i];
    while (tmp[i] > mid) tmp[i] >>= 1;
    if (tmp[i] == 0) return false;
    while (tmp[i] && vis[tmp[i]] == true) tmp[i] >>= 1;
    if (tmp[i] == 0) return false;
    vis[tmp[i]] = true;
  }
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &arr[i]);
  int l, r;
  l = 1, r = 2000000000;
  while (l < r) {
    int mid = l + ((r - l) >> 1);
    if (Check(mid)) {
      r = mid;
      for (int i = 1; i <= n; ++i) ans[i] = tmp[i];
    } else
      l = mid + 1;
  }
  for (int i = 1; i <= n; ++i) {
    if (i == 1)
      printf("%d", ans[i]);
    else
      printf(" %d", ans[i]);
  }
  return 0;
}
