#include <bits/stdc++.h>
#include <set>
#include <map>
#include <vector>
#include <cmath>
using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define WHAT ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define cin(x, N) for(int i = 1; i <= N; i ++) cin >> x[i]
#define reset(x, N) for(int i = 1; i <= N; i ++) x[i] = 0;
#define sortvec(x) sort(x.begin(), x.end())
#define open_file(intput, output) freopen("input","r",stdin);freopen("output","w",stdout)

int n,m;
int main(){
    WHAT
    int N, ans = 1;
    cin >> N;
    bool was = false;
    for(int i = 1; i <= 30; i ++){
        ans *= 2;
        if(N == ans - 1) was = true;
    }
    if(!was){
        cout << -1;
        exit(0);
    }
    int a[N + 1];
    cin(a, N);
    map <int, int> mp;
    for(int i = 1; i <= N; i ++){
        if(mp.count(a[i]) == 0) mp[a[i]] = 1;
        else mp[a[i]] ++;
    }
    ans = 1;
    int M = N;
    while(M > 0){
        //cout << ans << " ";
        M -= ans;
        for(int i = 1; i <= ans; i ++){
            if(mp.count((i - 1) * ((N / 2 + 1) / ans) + 1) == 0){
                //cout << (i - 1) * ((N / 2 + 1) / ans) + 1;
                cout << -1;
                exit(0);
            }
            if(mp[(i - 1) * ((N / 2 + 1) / ans) + 1] == 0){
                //cout << mp[(i - 1) * ((N / 2 + 1) / ans) + 1] << " ";
                cout << -1;
                exit(0);
            }
            mp[(i - 1) * ((N / 2 + 1) / ans) + 1] --;
        }
        ans *= 2;
    }
    for(int i = 1; i <= ans / 2; i ++) cout << i << " ";
}




