#include<bits/stdc++.h> 
using namespace std;

#define all(a) a.begin(),a.end()
#define pb push_back
#define vt vector
#define endl '\n'
typedef long long ll;

const int inf=1e9;
const int N=4e5+605;

int mins[N];

void solve(){
    int n;
    cin>>n;
    int a[n+2];
    int k=0;
    int z=n+1;
    map<int,int>mp;
    while(z){
        z/=2;
        ++k;
    }
    int ori=k;
    mins[1]=1;
    mins[2]=1;
    for(int i=4; i<N; i*=2){
        mins[i]=1;
    }
    set<int>st;
    for(int i=1; i<=n; ++i){
        cin>>a[i];
        mp[a[i]]--;
    }
    vt<pair<int,int>>v;
    for(auto [x,y]:mp){
        v.pb({y,x});
    }
    sort(all(v));
    sort(a+1,a+1+n);
    int ans[n+2];
    int l=1,r=n/2+1,mt=1;
    for(auto [x,y]:v){
        //cout<<x<<' '<<y<<' '<<k-1<<endl;
        if(-x!=k-1){
            cout<<-1<<endl;
            return;
        }
        ans[l]=y;
        ++l;
        k-=mins[mt];//double check
        mt++;
    }
    for(int i=1; i<=ori; ++i){
        cout<<ans[i]<<' ';
    }
}

int main(){
 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 int tt=1;
 //cin>>tt;
 while(tt--) {
  solve();
 }
}