#include <bits/stdc++.h>
using namespace std;
set<long long> s;
priority_queue<long long> pq;
int main() {
  long n, i, j;
  cin >> n;
  long long a[n], b[40], p, q;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    s.insert(a[i]);
    pq.push(a[i]);
  }
  b[0] = 2;
  for (i = 1; i < 40; i++) {
    b[i] = b[i - 1] * 2;
  }
  i = n - 1;
  while (j < 40) {
    for (j = 0; j < 40; j++) {
      if (s.count(pq.top() / b[j]) == 0 && pq.top() / b[j] != 0) {
        s.insert(pq.top() / b[j]);
        pq.push(pq.top() / b[j]);
        pq.pop();
        break;
      }
    }
  }
  while (!pq.empty()) {
    cout << pq.top() << " ";
    pq.pop();
  }
  return 0;
}
