#include <bits/stdc++.h>
#define int long long
#define sz size()
#define pb push_back
#define pf push_front
#define in insert
#define F first
#define S second
#define B begin()
#define E end()
using namespace std;

const int N = 1e5 + 7;
const int mod = 1e9 + 7;
const int inf = 1e10;
int n , a[N] , ans[N];

signed main() {
    set <int> st;
    vector <int> v;
    map <int , int> mp;
    queue <int> q;
    cin >> n;
    for (int i = 1; i <= n; i++){ 
        cin >> a[i];
        st.in(a[i]);
        mp[a[i]]++;
    }
    for (auto it : st) v.pb(it);
    int b=n , c=1 , cnt=1;
    while (b > c) {
        b -= c;
        c *= 2;
        cnt++;
    }
    sort (a + 1 , a + n + 1) ;
    if (st.sz != c || mp[a[1]] != cnt){
        cout << -1;
        return 0;
    }
    for (int i = 0; i < v.sz; i++) {
        if (mp[v[i]] > 1) q.push(v[i]);
    }
    for (int i = 1; i < v.sz; i++) {
        if (mp[v[i]] == 1){ 
            ans[q.front()] = v[i];
            q.pop();
        }
    }
    for (int i = 0; i < v.sz; i++) {
        if (mp[v[i]] > 1) cout << v[i] << ' ' << ans[v[i]] << ' ';
    }
}
