#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <bitset>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <vector>
#define fir first
#define sec second

template<typename T>
bool rMin(T& a, const T& b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool rMax(T& a, const T& b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}


using namespace std;


vector<int> td[200200];
int ans[200200];

vector<int> arr;

map<int, int> qsn;

void solve(){

    int qe, mtd = 0, rd;
    cin >> qe;
    if(qe == 1) {
        cin >> qe;
        cout << qe << '\n';
        return;
    }
    arr.assign(qe, 0);
    for(int i = 0; i < qe; ++i){
        cin >> arr[i];
        ++qsn[arr[i]];
    }
    sort(arr.rbegin(), arr.rend());

    for(int i = 0; (1 << i) < qe; ++i) ++mtd;
    rd = mtd;

    td[mtd] = {0};

    while(mtd > 0){
        int nind, cd;

        if(qsn[arr.back()] > mtd){
            cout << "-1\n";
            return;
        }
        else{
            cd = qsn[arr.back()];
            if(td[cd].empty()) {
                cout << "-1\n";
                return;
            }
            nind = td[cd].back();
            td[cd].pop_back();
        }

        for(int i = 1; i < cd; ++i){
            td[i].push_back(nind + (1 << (i - 1)));
        }
        ans[nind] = arr.back();

        arr.erase(arr.end() - cd, arr.end());

        while(td[mtd].empty() && mtd > 0) --mtd;
    }

    set<int> ch;
    for(int i = 0; i < (1 << (rd - 1)); ++i){
        ch.insert(ans[i]);
    }
    if(ch.size() != (1 << (rd - 1))){
        cout << "-1\n";
        return;
    }
    for(int i = 0; i < (1 << (rd - 1)); ++i) cout << ans[i] << ' ';
    cout << '\n';

}

int main(){
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    int t = 1;

    //cin >> t;

    for(int i = 0; i < t; ++i){
        solve();
    }
}