#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()

using namespace std;

const long long mod = 1000000007, mod3 = 998244353, inf = (ll)1e15;

struct T{
    ll x, y;
};

ll n;

ll k, a[1000005], b[1000005], t[400005 * 4], cur, tv[400005 * 4];

map <ll, ll> used, used2;

ll cnt[500005];

T p[500005];

queue <T> q;

void build(ll v = 1, ll tl = 1, ll tr = (n + 1) / 2){
    if (tl == tr){
        t[v] = b[tl];

        used2[t[v]]++;

        return;
    }

    ll tm = (tl + tr) >> 1;

    build(v + v, tl, tm);
    build(v + v + 1, tm + 1, tr);

    t[v] = min(t[v + v], t[v + v + 1]);

    used2[t[v]]++;
}

void update(ll ind, ll v = 1, ll tl = 1, ll tr = cur){
    if (tl == tr){
        tv[v] = 1;

        return;
    }

    ll tm = (tl + tr) >> 1;

    if (ind <= tm) update(ind, v + v, tl, tm);

    else update(ind, v + v + 1, tm + 1, tr);

    tv[v] = max(tv[v + v], tv[v + v + 1]);
}

ll get(ll l, ll r, ll v = 1, ll tl = 1, ll tr = cur){
    if (tl > r || l > tr) return 0;

    if (tl >= l && r >= tr) return tv[v];

    ll tm = (tl + tr) >> 1;

    return max(get(l, r, v + v, tl, tm), get(l, r, v + v + 1, tm + 1, tr));
}

void query(){
    cin >> n;

    set <ll> s;

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

        s.insert(a[i]);

        used[a[i]]++;
    }

    if (s.size() != (n + 1) / 2){
        cout << "-1";

        return;
    }

    for (auto i : s){
        p[++cur] = {i, used[i]};
    }

    sort (p + 1, p + cur + 1, [](T a, T b){
        if (a.y == b.y) return a.x < b.x;

        return a.y > b.y;
    });

    sort (p + 1, p + cur + 1, [](T a, T b){
        if (a.y == b.y) return a.x > b.x;

        return a.y < b.y;
    });

    ll l = 1;

    for (ll lg = cur; lg >= 1; lg >>= 1){
        for (ll j = 1; j + lg - 1 <= cur; j += lg){
            if (get(j, j + lg - 1) == 0){
                update(j);

                b[j] = p[l++].x;
            }
        }
    }


    build();

    for (auto i : s){
        if (used[i] != used2[i]){
            cout << -1;
            return;
        }
    }
    for(int i=1; i <= cur; i++){
        cout << b[i] << ' ';
    }

}
int main(){
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    ll TT = 1;

    //cin >> TT;

    while(TT--){
        query();
    }

    return 0;
}

/**

15
1 1 1 1 2 3 3 3 4 4 5 6 7 7 8


*/
