#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, B[N], l, r, Ans;
map<int, int> Map;
vector<int> A[N];
bool check(int x) {
  Map.clear();
  for (int j, i = 1; i <= n; i++) {
    for (j = 0; j < A[i].size(); j++) {
      if (A[i][j] > x) continue;
      if (Map.find(A[i][j]) == Map.end()) {
        Map[A[i][j]] = 1;
        break;
      }
    }
    if (j == A[i].size()) return 0;
  }
  return 1;
}
void solve(int x) {
  Map.clear();
  for (int j, i = 1; i <= n; i++) {
    for (j = 0; j < A[i].size(); j++) {
      if (A[i][j] > x) continue;
      if (Map.find(A[i][j]) == Map.end()) {
        Map[A[i][j]] = 1;
        printf("%d ", A[i][j]);
        break;
      }
    }
  }
  return;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &B[i]);
  sort(B + 1, B + n + 1);
  for (int x, i = 1; i <= n; i++) {
    x = B[i];
    r = max(x, r);
    while (x) {
      A[i].push_back(x);
      x = x >> 1;
    }
  }
  while (l <= r) {
    int mid = l + r >> 1;
    if (check(mid))
      r = mid - 1, Ans = mid;
    else
      l = mid + 1;
  }
  solve(Ans);
  return 0;
}
