#include <bits/stdc++.h>

#define pudge ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
//typedef tuple<ll, ll, ll> tll;

const ll INF = 2e18;
const double PI = acos(-1);
const ll MOD7 = 1e9 + (1000 - 7);
const ll MOD9 = 1e9 + 9;
const ll P = 31;
const ld E = 1e-6;
//const ll N = 6250001;
const ll N = 1000006;

//ll check(vector<ll> &used) {
//    for (int i = 0; i < used.size(); ++i)
//        if (used[i] == 0) return 0;
//    return 1;
//}


int main() {
    pudge;

//    freopen("minmax.in", "r", stdin);
//    freopen("minmax.out", "w", stdout);

    ll n;
    cin >> n;
    vector<ll> a(n);
    set<ll> s;
    map<int, int> mp;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        mp[a[i]]++;
        s.insert(a[i]);
    }
    if (n == 1) {
        cout << a[0] << "\n";
        return 0;
    }
    sort(a.begin(), a.end());
    if (s.size() * 2 != n + 1) {
        cout << -1 << "\n";
        return 0;
    }
    vector<ll> used(n, 0);
    set<ll> us;
    vector<ll> ans;
//    for (int i = 0; i < n; ++i) {
//        if (us.find(a[i]) == us.end()) {
//            used[i] = 1;
//            us.insert(a[i]);
//            mp[a[i]]--;
//            //ans.push_back(a[i]);
//        }
//    }
int cnt = 0;
    for (int _ = 0; (1 << cnt) != n + 1; ++_) {
        set<ll> now;
        set <ll> sl;
        vector<ll> idx;
        ans.clear();
        auto it = mp.begin();
        int mx = 0;
        for (int i = 0; i < mp.size(); i++, it++){
            if (it->second > mx){
                mx = it->second;
            }
        }
        it = mp.begin();
        for (int i = 0; i < mp.size(); i++, it++){
            if (it->second == mx){
                now.insert(it->first);
                sl.insert(it->first);
                //it->second--;
            }
            if (it-> second == mx - 1){
                sl.insert(it->first);
            }
        }
        set <int> st;
        int k = 0;
        if (now.size() * 2 == sl.size()){
            auto it2 = sl.begin();
            for (int i = 0; i < sl.size(); i++, it2++){
                if (now.find(*it2) != now.end()){
                    k++;
                    st.insert(*it2);
                }
                else{
                    k--;
                    if (k < 0) {
                        cout << -1;
                        return 0;
                    }


                        ans.push_back(*st.begin());
                        ans.push_back(*it2);
                        st.erase(st.begin());

                }
            }

        }
        else{
            cout << -1;
            return 0;
        }
        it = mp.begin();
        for (int i = 0; i < mp.size(); i++, it++){
            if (it->second == mx){
                it->second--;
                cnt++;
            }
        }


    }
    for (auto elem: ans)
        cout << elem << " ";
    cout << "\n";
    return 0;
}