#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void chkmax(T& x, U y) {
  if (x < y) x = y;
}
template <typename T, typename U>
inline void chkmin(T& x, U y) {
  if (y < x) x = y;
}
set<int> s;
set<int>::iterator it;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    s.insert(x);
  }
  while (1) {
    it = s.end();
    it--;
    int x = *it;
    int y = x / 2;
    while (s.count(y)) {
      y /= 2;
    }
    if (y == 0) break;
    s.erase(x);
    s.insert(y);
  }
  int k = 0;
  for (it = s.begin(); it != s.end(); it++) {
    k++;
    printf("%d%c", *it, (k < n) ? ' ' : '\n');
  }
  return 0;
}
