#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
const int MN = 1e5 + 5, LN = 17, MOD = 1e9 + 7, INF = 0x3f3f3f3f;
int n;
map<int, bool> inq;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  priority_queue<int> q;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    q.push(a);
    inq[a] = true;
  }
  vector<int> res;
  while (!q.empty()) {
    int cur = q.top();
    q.pop();
    inq[cur] = false;
    for (int i = cur; i > 0; i /= 2) {
      int nxt = i / 2;
      if (nxt == 0) {
        res.push_back(cur);
      } else if (!inq[nxt]) {
        q.push(nxt);
        inq[nxt] = true;
        break;
      }
    }
  }
  for (auto i : res) cout << i << " ";
  return 0;
}
