//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define ent "\n"
#define f first
#define s second

const int maxn = 1e6 + 100;
const int inf = (int)1e9 + 100;
const ll INF = (ll)1e18;
const int MOD = 1e9 + 7;
const int maxl = 20;
const ll P = 31;

int ans[maxn];

vector<int> get(vector<int> v,int len){
    map<int,int> cnt;
    if(v.size()==1){
        return v;
    }
    vector<int> t;
    for(int x:v){
        cnt[x]++;
        if(cnt[x]>=2)t.push_back(x);
    }
    if((int)v.size()!=(int)t.size()+len){
        cout<<-1;
        exit(0);
    }
    vector<int> g=get(t,len/2);
    set<int> st;
    for(int x:v){
        if(cnt[x]==1){
            st.insert(x);
        }
    }
    vector<int> ans;
    for(int x:g){
        if(st.lower_bound(x)==st.end()){
            cout<<-1;
            exit(0);
        }
        int y=*st.lower_bound(x);
        st.erase(y);
        if(x==y){
            cout<<-1;
            exit(0);
        }
        ans.push_back(x);
        ans.push_back(y);
    }
    return ans;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    cin>>n;
    vector<int> v;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        v.push_back(x);
    }
    vector<int> ans=get(v,(n+1)/2);
    for(int x:ans){
        cout<<x<<' ';
    }
    cout<<ent;
}
