

#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define sz(s) (int)s.size()
#define in insert
#define pii pair<int, int>
#define pb push_back

const int MAX=2e5+10;

int n;
int a[MAX];

int main(){
    cin>>n;
    set<int> st;
    map<int,int> cnt,c;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        cnt[a[i]]++;
        st.in(a[i]);
    }
    int n1=(n+1);
    if(sz(st)!=n1/2){
        cout<<-1<<"\n";
        return 0;
    }
    for(int x:st){
        c[cnt[x]]++;
    }
    int x=1;
    int l=__lg(n1);
    n1/=2;
    // cout<<l<<"\n";
    for(int i=l;i>=1;i--){
        c[i]+=c[i+1];
    }
    for(int i=1;i<=l;i++){
        if(c[i]==n1){
            n1/=2;
        }
        else{
            cout<<-1<<"\n";
            return 0;
        }
    }
    // cout<<n1<<"\n";
    for(int x:st)cout<<x<<" ";
}