#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int IT_MAX = 262144;
const int MOD = 1000000007;
const int INF = 1034567891;
const long long LL_INF = 1234567890123456789ll;
const double PI = 3.141592653589793238;
const long double ERR = 1E-11;
set<int> Sx;
int main() {
  int N, i, t;
  scanf("%d", &N);
  for (i = 1; i <= N; i++) {
    scanf("%d", &t);
    Sx.insert(t);
  }
  while (1) {
    auto it = Sx.end();
    it--;
    int u = *it;
    int t;
    for (t = u / 2; t >= 1; t /= 2)
      if (!Sx.count(t)) break;
    if (t == 0) {
      for (auto it : Sx) printf("%d ", it);
      return !printf("\n");
    }
    Sx.erase(u);
    Sx.insert(t);
  }
  return 0;
}
