#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const int N = 5e4 + 10;
int y[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", y + i);
  }
  int low = 1, high = 1e9;
  while (low != high) {
    int mid = (low + high) / 2;
    unordered_set<int> A;
    bool found = false;
    for (int i = 0; i < n; ++i) {
      int cur = y[i];
      while (cur > mid) cur >>= 1;
      while (cur > 1 && A.find(cur) != A.end()) cur >>= 1;
      if (A.find(cur) == A.end()) {
        A.insert(cur);
      } else {
        found = true;
        break;
      }
    }
    if (found) {
      low = mid + 1;
    } else {
      high = mid;
    }
  }
  unordered_set<int> A;
  for (int i = 0; i < n; ++i) {
    int cur = y[i];
    while (cur > high) cur >>= 1;
    while (cur > 1 && A.find(cur) != A.end()) cur >>= 1;
    if (A.find(cur) == A.end()) {
      A.insert(cur);
      printf("%d%c", cur, " \n"[i == n - 1]);
    }
  }
  return 0;
}
