#include <iostream>
#include <fstream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <string>
#include <set>
#include <cmath>
#include <limits.h>
#include <map>
#include <sstream>
#include <deque>
#include <queue>
#include <valarray>
#include <array>
#include <unordered_map>

#define rep(i, st, n) for(int (i) = (st); (i) < (n); ++(i))
#define repb(i, st, n) for(bool (i) = (st); (i) < (n); ++(i))
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define nl "\n"
int const INF = 1e9 + 1000 - 7;
typedef long long ll;
//#define int ll

using namespace std;

typedef unsigned long long ull;
typedef long double ld;
typedef string str;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef pair < ll, int > pli;
typedef vector <int> vi;
typedef vector < vector<int> > vvi;
typedef vector < pii > vpii;
typedef vector < pair<int, ll> > vpil;
typedef vector < ll > vll;


unordered_map<int, int> cnt;

bool cmp(int a, int b) {
    return cnt[a] > cnt[b];
}


int logg(int a) {
    int res = 0;
    while (a % 2 == 0) {
        res++;
        a /= 2;
    }
    return res;
}
int n;
vector<ll> t, ans;

void build(int v, int l, int r) {
    if (r - l == 1)
        t[v] = ans[l];
    else {
        int m = (r + l) / 2;
        build(2 * v + 1, l, m);
        build(2 * v + 2, m, r);
        t[v] = min(t[2 * v + 1], t[2 * v + 2]);
    }
}

void update(int v, int l, int r, int pos, ll val) {
    if (pos < l || pos >= r)
        return;
    if (r - l == 1)
        t[v] = val;
    else {
        int m = (r + l) / 2;
        update(2 * v + 1, l, m, pos, val);
        update(2 * v + 2, m, r, pos, val);
        t[v] = min(t[2 * v + 1], t[2 * v + 2]);
    }
}
ll get_min(int v, int l, int r, int a, int b) {
    if (b <= l || r <= a)
        return LLONG_MAX;
    if (a <= l && r <= b)
        return t[v];
    int m = (l + r) / 2;
    ll min_l = get_min(2 * v + 1, l, m, a, b);
    ll min_r = get_min(2 * v + 2, m, r, a, b);
    return min(min_l, min_r);
}


void solve() {
    int n; cin >> n;
    vll a;
    vll b(n);
    for (int i = 0; i < n; ++i) {
        int k; cin >> k;
        b[i] = k;
        if (!cnt[k]) {
            a.pb(k);
        }
        cnt[k]++;
    }
    sort(all(a), cmp);
    bool is = true;
    int m = (n + 1) / 2;
    vi cn(m);
    int lg = logg(m);
    int cr = lg;
    cn[0] = lg + 1;
    for (int i = 1; i < m; ++i) {
        int j = i;
        for (j = i; j < i + (1 << (lg - cr)); ++j) {
            cn[j] = cr;
        }
        cr--;
        i = j - 1;
    }
    ans.resize(m);
    for (int i = 0; i < m; ++i) {
        if (cnt[a[i]] != cn[i]) {
            is = false;
            break;
        }
    }
    if (!is) {
        cout << -1;
        return;
    }
    map<int, vector<int>> mp; // числа для кнт 
    for (int i = 0; i < m; ++i) {
        mp[cnt[a[i]]].pb(a[i]);
    }
    unordered_map<int, vi> pos;

    ans[0] = mp[lg + 1][0];
    if(n != 1) ans[m / 2] = mp[lg][0];
    pos[lg + 1].pb(0);
    if (n != 1) pos[lg].pb(m / 2);
    for (int i = lg - 1; i >= 1; --i) {
        for (int j = lg + 2; j > i; --j) {
            for (auto k : pos[j]) {
                int new_pos = k + (1 << (i - 1));
                pos[i].pb(new_pos);
            }
        }
    }
    //for (auto i : mp) sort(all(mp[i.first]));
    for (auto i : pos) sort(all(pos[i.first]));
    for (auto i : pos) {
        for (int j = 0; j < i.second.size(); ++j) {
            ans[i.second[j]] = mp[i.first][j];
        }
    }
    t = vector<ll>(4 * m);
    build(0, 0, m);
    vll t4;
    for (auto i : t) {
        if (i != 0) t4.pb(i);
    }
    sort(all(t4));
    sort(all(b));
    for (int i = 0; i < t4.size(); ++i) {
        if (t4[i] != b[i]) {
            is = false;
        }
    }
    if (!is) {
        cout << -1;
        return;
    }
    for (int i = 0; i < m; ++i) cout << ans[i] << ' ';
}

signed main()
{
    cin.tie(0); ios::sync_with_stdio(0); cout.tie(0);
    int t = 1;// cin >> t;
    while (t--) {
        solve();
    }
}
