#include<iostream>
#include<vector>
#include<string>  
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<cstdio>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//=================================

ld bpow(ld a, ll n) {
    if (n == 0) {
        return 1;
    }
    if (n % 2 == 0) {
        ld b = bpow(a, n / 2);
        return b * b;
    }
    else {
        return bpow(a, n - 1) * a;
    }
}


void solve() {
    int m;
    cin >> m;
    int n = (m + 1) / 2;
    int lg = log2(m + 1);
    vector<int> a(n);
    map<int, int> c;
    for (int i = 0; i < m; ++i) {
        int t;
        cin >> t;
        c[t]++;
    }
    if (c.size() != n) {
        cout << -1;
        return;
    }
    vector<int> ind(lg + 1);
    for (int i = 1; i <= lg; ++i) {
        ind[i] = (1 << (i) - 1) % n;
    }
    for (auto i : c) {
        if (ind[i.second] >= n) {
            cout << -1;
            return;
        }
        a[ind[i.second]] = i.first;
        ind[i.second] += (1 << i.second);
    }
    
    for (int j = 1; j < lg; ++j) {
        for (int i = 0; i < n; i += (1 << j)) {
            if (a[i] >= a[i + (1 << (j - 1))]) {
                cout << -1;
                return;
            }
        }
    }
    for (auto i : a) {
        if (i == 0){
            cout << -1;
            return;
        }
    }
    for (auto i : a) cout << i << ' ';
}

//=================================

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int tt = 1;
    //cin >> tt;
    while (tt--) {
        solve();
        cout << '\n';
    }
    return 0;
}