#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <cassert>
#include <random>
#include <chrono>
#include <tuple>

#pragma GCC optimize("03")
#pragma GCC target("avx2")

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ii = int;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

using namespace std;

vector <map<ii, ii>> vmp;
vector <pair<ii, ii>> v;
ii mxlvl = 1;
unordered_set<ii> answer;

void out(ii lvl, ii ind) {
    if (lvl == 1) {
        ii ans = vmp[lvl - 1][ind];
        answer.insert(ind);
        answer.insert(ans);
        cout << ind << ' ' << ans << ' ';
        return;
    }
    else {
        out(lvl - 1, ind);
        out(lvl - 1, vmp[lvl - 1][ind]);
    }
}

void func(ii lvl) {
    if (lvl == mxlvl) {
        ii cnt = 0;
        ii keki = 0;
        for (ii i = 0; i < v.size(); ++i) {
            if (v[i].second == mxlvl) {
                if (cnt >= 1) {
                    cout << -1;
                    exit(0);
                }
                keki = v[i].first;
                cnt++;
            }
        }
        out(lvl - 1, keki);
        return;
    }
    deque<ii> dq;
    map <ii, ii> pairs;
    for (ii i = 0; i < v.size(); ++i) {
        if (v[i].second > lvl) {
            dq.push_back(v[i].first);
        }
        else if (v[i].second == lvl) {
            if (dq.size() < 1) {
                //cout << lvl;
                cout << -1;
                exit(0);
            }
            pairs[dq.back()] = v[i].first;
            dq.pop_back();
        }
    }
    vmp.push_back(pairs);

    if (dq.size() != 0) {
        //cout << lvl << ' ';
        cout << -1;
        exit(0);
    }

    func(lvl + 1);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ii n;
    cin >> n;
    map <ii, ii> mp;
    for (ii i = 0; i < n; ++i) {
        ii now;
        cin >> now;
        mp[now]++;
    }

    if (n == 1) {
        cout << mp.begin()->first;
        return 0;
    }

    if (mp.size() * 2 - 1 != n) {
        cout << -1;
        exit(0);
    }

    v.resize((ii)mp.size());
    ii cnt = 0;
    for (auto it : mp) {
        if (cnt >= mp.size()) {
            cout << -1;
            return 0;
        }
        v[cnt] = it;
        mxlvl = max(mxlvl, it.second);
        cnt++;
    }

    func(1);

    return 0;
}
