#include <bits/stdc++.h>

using namespace std;

vector<int> ans;
map<int, int> K;

int make(int l, int r) {
    if (r - l == 1) {
        K[ans[l]]++;
        return ans[l];
    }
    int now = min(make(l, (l + r) / 2), make((l + r) / 2, r));
    K[now]++;
    return now;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        k[a[i]]++;
    }
    vector<pair<int, int>> kol;
    for (auto [x, k1] : k) {
        kol.push_back({x, k1});
    }
    sort(kol.begin(), kol.end(), [&] (pair<int, int> a1, pair<int, int> b1) {
        return a1.second > b1.second;
    });
    int N = (n + 1) / 2;
    if (kol.size() != N) {
        cout << -1;
        exit(0);
    }
    ans.resize(N);
    vector<int> p;
    int ad = N / 2;
    vector<int> used(N);
    int now = 0;
    while (ad > 0) {
        while (now < N) {
            if (!used[now]) {
                p.push_back(now);
                used[now] = true;
            }
            now += ad;
        }
        now = 0;
        ad /= 2;
    }
    if (p.empty()) {
        p = {0};
    }
    for (int i = 0; i < N; i++) {
        ans[p[i]] = kol[i].first;
    }
    make(0, N);
    if (k == K) {
        for (auto x : ans) {
            cout << x << ' ';
        }
    }
    else {
        cout << -1;
    }
}