#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int N = 2e6;
vector<int> g[N];
long long a[N];
vector<int> A;
int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);
map<int, set<int>> way;
map<int, set<int>> del;
map<int, int> cnt;
int n;
void go() {
  int i;
  way.clear();
  del.clear();
  for (i = 0; i < n; i++) {
    int x = A[i];
    int no = x;
    while (x) {
      way[no].insert(x);
      del[x].insert(no);
      x = x / 2;
    }
  }
}
int f(int mx) {
  int i;
  set<int> used;
  used.clear();
  for (i = (int)A.size() - 1; i >= 0; i--) {
    int x = A[i];
    int pos = x;
    while (pos > mx or used.find(pos) != used.end()) pos /= 2;
    if (pos == 0) return 0;
    used.insert(pos);
  }
  return 1;
}
int bin(int lo, int hi) {
  if (lo == hi) return lo;
  if (lo + 1 == hi) {
    if (f(lo)) return lo;
    return hi;
  }
  int mid = (lo + hi) / 2;
  if (f(mid)) return bin(lo, mid);
  return bin(mid + 1, hi);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int m, t, i, u, j, v, w, x;
  vector<int> pre;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> x;
    int no = x;
    A.push_back(x);
  }
  vector<int> ans;
  sort(A.begin(), A.end());
  int lim = bin(1, A[(int)A.size() - 1]);
  int mx = lim;
  set<int> used;
  for (i = (int)A.size() - 1; i >= 0; i--) {
    int x = A[i];
    int pos = x;
    while (pos > mx or used.find(pos) != used.end()) pos /= 2;
    if (pos == 0) return 0;
    ans.push_back(pos);
    used.insert(pos);
  }
  for (int x : ans) cout << x << " ";
  return 0;
}
int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((long long)result * base) % mod;
    base = ((long long)base * base) % mod;
    exp >>= 1;
  }
  return result;
}
void ipgraph(int n, int m) {
  int i, u, v;
  while (m--) {
    cin >> u >> v;
    g[u - 1].push_back(v - 1);
    g[v - 1].push_back(u - 1);
  }
}
void dfs(int u, int par) {
  for (int v : g[u]) {
    if (v == par) continue;
    dfs(v, u);
  }
}
