#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int mod = 1000000007;
const double PI = acos(-1.0);
int a[51005];
int b[51005];
int c[51005];
bool vis[51005];
int n, m;
int ans;
struct node {
  int x, id;
  node() {}
  node(int xx, int i) {
    x = xx;
    id = i;
  }
  bool operator<(const node &b) const { return x < b.x; }
};
set<int> s;
int main() {
  int tt, ca = 1;
  int p, q;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    s.insert(-a[i]);
  }
  set<int>::iterator it;
  while (1) {
    p = *s.begin();
    q = -p;
    int now = 0;
    while (q > 0) {
      q /= 2;
      if (q > 0 && s.count(-q) == 0) {
        now = 1;
        break;
      }
    }
    if (now == 0) break;
    s.erase(p);
    s.insert(-q);
  }
  for (it = s.begin(); it != s.end(); it++) printf("%d ", -*it);
  printf("\n");
  return 0;
}
