#include <bits/stdc++.h>
using namespace std;
int n;
vector<int64_t> v;
bool get(int64_t x, set<int64_t>& ans) {
  ans.clear();
  for (int i = 0; i < n; ++i) {
    bool is = false;
    int64_t m = v[i];
    do {
      if (m <= x && ans.count(m) == 0) {
        ans.insert(m);
        is = true;
        break;
      }
      m /= 2;
    } while (m);
    if (!is) break;
  }
  if (ans.size() != n) return false;
  return true;
}
void solve() {
  cin >> n;
  v.resize(n);
  int64_t l = 0, r = 0;
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
    r = max(r, v[i]);
  }
  sort(v.begin(), v.end());
  set<int64_t> w;
  while (r - l > 1) {
    int64_t m = (l + r) / 2;
    if (get(m, w)) {
      r = m;
    } else {
      l = m;
    }
  }
  for (int64_t u = l; u <= r; ++u) {
    if (get(u, w)) break;
  }
  for (auto& x : w) {
    cout << x << " ";
  }
}
int main(void) {
  std::ios_base::sync_with_stdio(false);
  solve();
  return 0;
}
