#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pp pair<ll,ll>
#define pb push_back
template<class T> istream& operator>>(istream& is, vector<T>& arr) { for(auto& i:arr) is>>i; return is;}
template<class T> ostream& operator<<(ostream& os, vector<T>& arr) { for(auto& i:arr) os<<i<<" "; return os;}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(30);

    int n; cin >> n;
    vector<int> a(n); cin >> a;
    map<int, int> cnt;

    for(auto &x : a) cnt[x]++;

    int m = (n + 1) / 2;

    sort(all(a));
    a.erase(unique(all(a)), a.end());

    vector<int> v1, v2, v3; int i = (int)__lg(n+1);
    for(auto &x : a) {
        if(cnt[x] == i) v1.pb(x);
    }
    for(int i=(int)__lg(n+1);i>=2;i--) {
        v2.clear();
        v3.clear();

        for(auto &x : a) {
            if(cnt[x] == i-1) v2.pb(x);
        }

        if(v1.size() != v2.size()) { cout << -1 << endl; return 0; }

        for(int j=0;j<(int)v1.size();j++) {
            if(v1[j] > v2[j]) { cout << -1 << endl; return 0; }
            v3.pb(v1[j]); v3.pb(v2[j]);
        }

//        cout << v1 << endl << v2 << endl << v3 << endl << endl;
        swap(v1, v3);
    }

    if(v1.size() != m) { cout << -1 << endl; return 0; }
    for(int i=0;i<(int)v1.size();i++)
        cout << v1[i] << ' ';
    return 0;
}
