#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int dr8[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dc8[] = {1, -1, 0, 0, -1, 1, -1, 1};
int dr4[] = {0, 1, -1, 0};
int dc4[] = {1, 0, 0, -1};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int x;
  vector<int> v;
  priority_queue<int> pq;
  set<int> s, ans;
  int an[n];
  for (int i = 0; i < n; i++) {
    cin >> x;
    s.insert(x);
    v.push_back(x);
    pq.push(x);
  }
  sort(v.begin(), v.end());
  while (!pq.empty()) {
    int f = pq.top();
    int tm = f;
    pq.pop();
    s.erase(s.find(tm));
    int mn = tm;
    while ((tm / 2) > 0) {
      tm /= 2;
      if (s.find(tm) == s.end()) {
        mn = tm;
        break;
      }
    }
    if (mn == f) {
      ans.insert(mn);
    } else {
      pq.push(mn);
      s.insert(mn);
    }
  }
  set<int>::iterator it = ans.begin();
  while (it != ans.end()) {
    cout << *it << " ";
    it++;
  }
}
