#include <bits/stdc++.h>
using namespace std;
const int maxm = 2e5 + 10;
set<int> g;
queue<set<int> > q;
int m, n, x, y;
int dfs(int top) {
  if (abs(top) <= 1) return 0;
  int now = 0;
  if ((-top) % 2 == 0)
    now = top / 2;
  else
    now = (top + 1) / 2;
  if (g.find(now) == g.end()) {
    g.erase(top);
    g.insert(now);
    return 1;
  } else
    return dfs(now);
}
int main() {
  cin >> m;
  for (int i = 1; i <= m; i++) {
    cin >> x;
    g.insert(-x);
  }
  for (;;) {
    int top = *g.begin();
    if (!dfs(top)) break;
  }
  for (auto e : g) cout << -e << " ";
  cout << endl;
  return 0;
}
