#include <bits/stdc++.h>
using namespace std;
long long int brr[100005];
long long int siz[100005];
long long int root(long long int a) {
  while (a != brr[a]) a = brr[a];
  return a;
}
void uni(long long int a, long long int b) {
  long long int x = root(a);
  long long int y = root(b);
  if (x != y) {
    if (siz[x] > siz[y]) {
      brr[y] = x;
      siz[x] += siz[y];
      siz[y] = 0;
    } else {
      brr[x] = y;
      siz[y] += siz[x];
      siz[x] = 0;
    }
  }
}
int main() {
  long long int n;
  cin >> n;
  unordered_map<long long int, long long int> ma;
  long long int arr[n];
  priority_queue<long long int> q;
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
    q.push(arr[i]);
    ma[arr[i]]++;
  }
  sort(arr, arr + n);
  while (!q.empty()) {
    long long int ptr = 0;
    long long int ff = q.top();
    for (long long int i = 2; i <= ff; i *= 2) {
      long long int d = ff / i;
      if (d == 0) break;
      if (ma[d] == 0) {
        q.pop();
        q.push(d);
        ma[d]++;
        ptr++;
        break;
      }
    }
    if (ptr == 0) {
      break;
    }
  }
  while (!q.empty()) {
    cout << q.top() << " ";
    q.pop();
  }
}
