#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
vector <ll> tree(400004,0);
vector <ll> razn;
void build_tree(ll v,ll tl,ll tr)
{
    if(tl==tr)
    {
        tree[v]=razn[tl];
    }
    else
    {
        ll tm=(tl+tr)/2;
        build_tree(v*2,tl,tm);
        build_tree(v*2+1,tm+1,tr);
        tree[v]=min(tree[v*2],tree[v*2+1]);
    }
}
int main()
{
    ll n;
    cin>>n;
    tree.resize(n+1);
    vector <ll> vec(n+1);
    for(ll i=1;i<=n;i++)
    {
        cin>>vec[i];
    }
    sort(vec.begin(),vec.end());
    set <ll> s;
    for(ll i=1;i<=n;i++)
    {
        s.insert(vec[i]);
    }
    razn.push_back(0);
    for(auto it:s)
    {
        razn.push_back(it);
    }
    ll numb=n,pos=-1;
    numb++;
    for(ll i=0;i<25;i++)
    {
        if((1<<i)==numb)
        {
            pos=i;
        }
    }
    pos--;
    if(int(razn.size())-1!=(1<<pos))
    {
        cout<<-1;
        return 0;
    }
    build_tree(1,1,int(razn.size())-1);
    sort(tree.begin(),tree.end());
    bool flag=1;
    for(int i=1;i<=n;i++)
    {
        if(vec[i]!=tree[i])
        {
            flag=0;
            break;
        }
    }
    if(!flag)
    {
        cout<<-1;
    }
    else
    {
        for(int i=1;i<int(razn.size());i++)
        {
            cout<<razn[i]<<" ";
        }
    }
    return 0;
}