#include <bits/stdc++.h>

using namespace std;

map<int, int> two;

int main()
{
    int da = 1, i = 0;
    while(da < 2 * 1e5){
        two[da] = i;
        da *= 2;
        i++;
    }
    int n;
    cin >> n;
    vector<int> a(n);
    for(int& i : a) cin >> i;
    sort(a.begin(), a.end());
    int k = two[n + 1];
    vector<int> ans;
    a.push_back(0);
    bool thing = false;
    for(int i = 0; i < n;){
        //cout << a[i] << " " << a[i + k - 1] << endl;
        if(a[i] == a[i + k - 1] && a[i] != a[i + k]) {
                ans.push_back(a[i]);
                i += k;
                k--;
                thing = true;
        }
        if(thing){
            ans.push_back(a[i]);
            i++;
            thing = false;
        }
        else{
            cout << -1;
            return 0;
        }
    }
    for(auto u : ans) cout << u << " ";
}
