#include <bits/stdc++.h>
using namespace std;
int N;
int A[100010];
int check(int K, set<int> &X) {
  X.clear();
  priority_queue<int> que;
  for (int i = 0; i < N; i++) {
    que.push(A[i]);
  }
  while (!que.empty()) {
    int x = que.top();
    que.pop();
    if (x > K || (X.find(x) != X.end() && x > 1)) {
      que.push(x / 2);
    } else {
      X.insert(x);
    }
  }
  return X.size();
}
int func(int K) {
  set<int> X;
  int ret = -1;
  int lo = 1, hi = 1000000000;
  while (lo <= hi) {
    int mid = (lo + hi) / 2;
    int temp = check(mid, X);
    if (temp >= K) {
      hi = mid - 1;
      if (temp == K) ret = mid;
    } else {
      lo = mid + 1;
    }
  }
  return ret;
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  set<int> S;
  int ans = func(N);
  check(ans, S);
  for (auto it : S) {
    printf("%d ", it);
  }
}
