#include <bits/stdc++.h>
using namespace std;
template <class T>
void splitstr(const string &s, vector<T> &out) {
  istringstream in(s);
  out.clear();
  copy(istream_iterator<T>(in), istream_iterator<T>(), back_inserter(out));
}
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
static void redirect(int argc, const char **argv) {
  ios::sync_with_stdio(false);
  if (argc > 1) {
    static filebuf f;
    f.open(argv[1], ios::in);
    cin.rdbuf(&f);
    if (!cin) {
      cerr << "Failed to open '" << argv[1] << "'" << endl;
      exit(1);
    }
  }
  if (argc > 2) {
    static filebuf f;
    f.open(argv[2], ios::out | ios::trunc);
    cout.rdbuf(&f);
    if (!cout) {
      cerr << "Failed to open '" << argv[2] << "'" << endl;
    }
  }
}
int main(int argc, const char **argv) {
  redirect(argc, argv);
  int N;
  cin >> N;
  vector<int> y(N);
  for (int i = 0; i < N; i++) cin >> y[i];
  long long hi = *max_element(begin(y), end(y));
  long long lo = 0;
  while (hi - lo > 1) {
    long long mid = (lo + hi) / 2;
    unordered_set<int> seen;
    for (int v : y) {
      while (v > mid) v >>= 1;
      while (!seen.insert(v).second) v >>= 1;
      if (v == 0) goto bad;
    }
    hi = mid;
    continue;
  bad:
    lo = mid;
  }
  unordered_set<int> seen;
  bool first = true;
  for (int v : y) {
    while (v > hi) v >>= 1;
    while (!seen.insert(v).second) v >>= 1;
    if (!first) cout << ' ';
    cout << v;
    first = false;
  }
  cout << '\n';
  return 0;
}
