#include<bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 2e5 + 10;

int n, m;
int a[N];

set<int> st[N];
int t[N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++) 
        cin >> a[i];
    m = (n + 1) / 2;
    vector<pair<int, int>> b;
    map<int, int> mp;
    for(int i = 1; i <= n; i++) 
        mp[a[i]]++;

    if(mp.size() != m) {
        cout << -1;
        return 0;
    }

    for(auto [x, y] : mp) {
        st[y].insert(x);
    }
    
    int cur = 1;
    for(int len = n; len >= 1; len--) {
        while(!st[len].empty()) {
            while(t[cur]) cur++;

            auto it = st[len].upper_bound(t[cur / 2]);
            if(it == st[len].end()) {
                cout << -1;
                return 0;
            }
            int k = len;
            int val = *it;
            st[len].erase(it);
            for(int i = cur; i <= n; i *= 2) {t[i] = val; k--;}
            if(k != 0) {
                cout << -1;
                return 0;
            }
        }
    }
    for(int i = m; i <= n; i++) cout << t[i] << ' ';
}
