//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

    typedef long long ll;
    typedef long double ld;

set<pair<int, int>> st;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        mp[a[i]]++;
    }
    for (auto [k, v] : mp) {
        st.insert({v, -k});
    }
    vector<int> tr(n + 1);
    for (int i = 1; i <= n; i++) {
        if (tr[i] == 0) {
            if (st.empty()) break;
            tr[i] = -(*st.rbegin()).second;
            st.erase((*st.rbegin()));
        }
        if (i * 2 <= n) {
            tr[i * 2] = tr[i];
        }
    }
    bool good = true;
    map<int, int> mp1;
    for (int i = 1; i <= n; i++) {
        if (i * 2 + 1 <= n && tr[i] != min(tr[i * 2], tr[i * 2 + 1])) {
            good = false;
        }
        mp1[tr[i]]++;
    }
    if (!good || mp1 != mp) {
        cout << -1 << '\n';
        return;
    }
    for (int i = n / 2 + 1; i <= n; i++) {
        cout << tr[i] << ' ';
    }
    cout << '\n';
}

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

    int t = 1;
    //cin >> t;

    while (t--) {
        solve();
    }
}
