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

void solve(){
    int n;
    cin >> n;
    vector<int>a(n);
    unordered_map<int,int>mp;
    for(int i = 0; i < n; ++ i){
        cin >> a[i];
        mp[a[i]] ++ ;
    }
    int st = __lg(n) + 1;
    sort(a.begin(),a.end());
    a.erase(unique(a.begin(),a.end()),a.end());
    while(st > 0){
        bool f = 0;
        for(auto [x,y] : mp){
           if(y == st){
            f = 1;
            break;
           }
        }
        if(!f){
            cout << "-1\n";
            return;
        }
        st -- ;
    }
    for(auto to : a)cout << to << ' ';
}

int32_t main(){
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif // LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int Q = 1;
//    cin >> Q;
    while(Q -- )solve();
    return 0;
}
