#include <bits/stdc++.h>
using namespace std;
vector<string> split(const string &s, char c) {
  vector<string> v;
  stringstream ss(s);
  string x;
  while (getline(ss, x, c)) v.push_back(x);
  return v;
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cerr << "[DEBUG] " << it->substr((*it)[0] == ' ', it->length()) << " = " << a
       << '\n';
  err(++it, args...);
}
const int MOD = 1000000007;
template <class T, class U>
inline T tmin(T a, U b) {
  return (a < b) ? a : b;
}
template <class T, class U>
inline T tmax(T a, U b) {
  return (a > b) ? a : b;
}
template <class T, class U>
inline void amax(T &a, U b) {
  if (b > a) a = b;
}
template <class T, class U>
inline void amin(T &a, U b) {
  if (b < a) a = b;
}
template <class T>
inline T tabs(T a) {
  return (a > 0) ? a : -a;
}
template <class T>
T gcd(T a, T b) {
  while (b != 0) {
    T c = a;
    a = b;
    b = c % b;
  }
  return a;
}
const int N = 50005;
vector<int> g[N];
int ans[N];
int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> y(n);
  for (int i = (0); i < (n); ++i) cin >> y[i];
  sort(y.begin(), y.end());
  reverse(y.begin(), y.end());
  int mx = y[0];
  for (int i = (0); i < (n); ++i) {
    int x = y[i];
    while (x) {
      g[i].push_back(x);
      x >>= 1;
    }
  }
  int lb = n - 1, rb = mx;
  unordered_map<int, bool> vis;
  while (rb - lb > 1) {
    int mb = (rb + lb) >> 1;
    bool good(true);
    for (int i = (0); i < (n); ++i) {
      bool found(false);
      for (int x : g[i]) {
        if (x > mb) continue;
        if (vis.count(x) == 0) {
          vis[x] = 1, found = true;
          break;
        }
      }
      good &= found;
      if (!found) break;
    }
    if (good)
      rb = mb;
    else
      lb = mb;
    vis.clear();
  }
  for (int i = (0); i < (n); ++i) {
    for (int x : g[i]) {
      if (x > rb) continue;
      if (vis.count(x) == 0) {
        ans[i] = x, vis[x] = 1;
        break;
      }
    }
  }
  for (int i = (0); i < (n); ++i) {
    if (i < n - 1)
      printf("%d ", ans[i]);
    else
      printf("%d\n", ans[i]);
  }
  return 0;
}
