#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define all(a) a.begin() , a.end()
#define Yes cout<<"Yes\n";
#define YES cout<<"YES\n";
#define No cout<<"No\n";
#define NO cout<<"NO\n";
#define endl '\n'
#define fi first
#define se second
using namespace std;
const ll  modd = 1e9 + 7;
ll counter;
ll qpow_mod(ll  a, ll n, ll mod)
{
    if(n == 0LL)
    {
        return 1LL;
    }
    if(n%2 == 1)
    {
        return (a*qpow_mod(a, n-1, mod))%mod;
    }
    ll tmp = qpow_mod(a, n/2, mod);
    return (tmp*tmp)%mod;
}
ld qpow(ld  a, ll n)
{
    if(n == 0LL)
    {
        return 1LL;
    }
    if(n%2 == 1)
    {
        return (a*qpow(a, n-1));
    }
    ll tmp = qpow(a, n/2);
    return (tmp*tmp);
}
ll w(ll x)
{
    ll r = (x%modd);
    return r;
}
ll lcm(ll a,ll b)
{
    ll g=__gcd(a,b);
    return (a*b/g);
}
ld get_distance(ld x , ld y , ld x1 , ld y2){
    return sqrt( ((x-x1) * (x-x1)) +  ((y-y2)*(y-y2))  );
}

bool ans = true;



void solve(){
   ll n;
   cin >> n;
   set <ll> s;
   map <ll,ll> m1;
   map <ll,ll> m2;
   for(int i =0; i < n;i++){
        ll x;
        cin >> x;
        m1[x]++;
        s.insert(x);
   }
   ll w = 0;
   for(auto g: s){
       if(g == w+1){
           w++;
       }
       m2[m1[g]]++;
   }
   ll q = 1;
   ll ss =0;
   ll add = log2(w)+1;
   while(q <= w){
       m2[add] -= (q-ss);
       //cout<<add<<" "<<m2[add] <<" "<<(q-ss)<<endl;
       if(m2[add] != 0){
           cout<<-1<<endl;
           return;
       }
       ss =q;
       add--;
       q*=2;
   }
   q/=2;
   if(q != w){
        cout<<-1<<endl;
        return;
   }
   for(int i = 1;i <= w;i++){
        cout<<i<<" ";
   }



}

//11 41 14 44
//12 24 43 31

//{i,j} , {j , n-i+1} , {n-i+1 , n-j+1} ,{n-j-1 . i}





int main()
{



    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);

    //freopen("wall.in" , "r" , stdin);freopen("wall.out" , "w" , stdout);
    //fflush(stdout);
    ll t1 = 1;

    //cin >> t1;
    while (t1--)
    {

        solve();



    }
}
