#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[300005 * 4];

map <ll, ll> used, used2;

T p[500005];

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 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;
    }

    ll cur = 0;

    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 / 2 + 1, [](T a, T b){
        if (a.y == b.y) return a.x < b.x;

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

    ll l = 1, r = cur;

    ll tl = 1, tr = cur;

    for (ll i = 1; i <= cur / 2; i++){
        if (i & 1){
            b[tl] = p[l].x, b[tl + 1] = p[r].x;

            tl += 2;
        }

        else{
            b[tr] = p[l].x, b[tr - 1] = p[r].x;

            tr -= 2;
        }

        l++, r--;
    }

    build();

    for (auto i : s){
        if (used[i] != used2[i]){
            cout << -1;

            return;
        }
    }

    for (ll 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;
}

/**

*/
