#include<bits/stdc++.h>
#define f first
#define s second
#define ll long long
using namespace std;

bool cmp(pair<ll, ll> a, pair<ll, ll> b)
{
    if(a.f == b.f)
        return a.s < b.s;
    return a.f > b.f;
}

int main()
{

    ll n, i, j = 0, k;

    cin >> n;
    ll n0 = n / 2 + 1;

    vector<ll> a(n + 1), t(n + 1);

    map<ll, ll>m;

    for(i = 1; i <= n; ++i)
    {
        cin >> a[i];
        ++m[a[i]];
    }

    pair<ll, ll> p[n0 + 1];

    for(i = 1; i <= n; ++i)
    {
        if(m[a[i]])
        {
            p[++j] = {m[a[i]], a[i]};
            m[a[i]] = 0;
        }
    }

    sort(p + 1, p + n0 + 1, cmp);

    j = 1;
    for(i = 1; i <= n0; ++i)
    {
//        cout << p[i].s << ' ';
        while(t[j])
            ++j;

        for(k = j; k <= n; k *= 2)
        {
            if(!p[i].f)
            {
                cout << -1;
                return 0;
            }
            --p[i].f;
            t[k] = p[i].s;
        }
    }
//    cout << '\n';
    for(i = 1; i <= n / 2; ++i)
        if(t[i] > min(t[i] * 2, t[i] * 2 + 1))
            {
                cout << -1;
                return 0;
            }

    for(i = n / 2 + 1; i <= n; ++i)
        cout << t[i] << ' ';
}

