#include <bits/stdc++.h>
using namespace std;
const int N = 50005;
int n, a;
multiset<int> st;
bool backtrack(bool ord, int x, bool ok = false) {
  if (!ord && x == 1) return false;
  if (ord) {
    int tmp = *(--st.end());
    multiset<int>::iterator it = st.find(tmp), it1 = it;
    st.erase(it, ++it1);
    int t = tmp / 2;
    bool go = st.find(t) != st.end();
    st.insert(t);
    if (go) {
      if (backtrack(false, t, false)) return true;
    } else {
      if (backtrack(true, -1, true)) return true;
    }
    it = st.find(t), it1 = it, it1++;
    st.erase(it, it1);
    st.insert(tmp);
  } else {
    int tmp = x;
    multiset<int>::iterator it = st.find(tmp), it1 = it;
    st.erase(it, ++it1);
    int t = tmp / 2;
    bool go = st.find(t) != st.end();
    st.insert(t);
    if (go) {
      if (backtrack(false, t, false)) return true;
    } else {
      if (backtrack(true, -1, true)) return true;
    }
    it = st.find(t), it1 = it, it1++;
    st.erase(it, it1);
    st.insert(tmp);
  }
  return ok;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a);
    st.insert(a);
  }
  if (n == 1) return cout << 1, 0;
  backtrack(true, -1, true);
  for (__typeof(st.begin()) it = st.begin(); it != st.end(); ++it)
    printf("%d ", *it);
  return 0;
}
