#include <bits/stdc++.h>
using namespace std;
#define ios ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fr first
#define sc second
#define endl "\n"
#define ll long long
//#define int ll
void fopn(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const ll N=2e5+5,INF=1e18,mod=1e9+7;
vector<vector<int>> A(30);
vector<int> ans,res;
int n;
void dfs(int x=1, int v=1){
	if(x>n) return;
	if(2*x>n) ans.pb(v);
	dfs(x*2,v+1);
	dfs(2*x+1,1);
}

void f(int x, int lay){
	 if(lay==1){
		res.pb(x);
		return;
     }
	 f(x,lay-1);
	 if(A[lay-1].back()<x){
		 cout<<-1<<endl;
	 	 exit(0);
	 }
	 int it=A[lay-1].back();
	 f(it,lay-1);
	 A[lay-1].pop_back();
}
void solve(){
	int mn = 1e9;
	 cin>>n;
	 vector<int> a(n);
	 for(int i=0;i<n;i++){
		 cin>>a[i];
		 mn=min(mn,a[i]);
	 }
	 dfs();
	 //sort(all(a));
	 map<int,int> mp;
	 set<int> st;
	 for(int i=0;i<n;i++){
		 mp[a[i]]++;
		 st.insert(-a[i]);
	 }
	 if((int)st.size()!=(n+1)/2){
		 cout<<-1<<endl;
		 return;
	 }
	 for(auto it: st)
		 A[mp[-it]].pb(-it);
	 if(A[ans[0]].size()!=1){
		 cout<<-1<<endl;
		 return;
	 }
	 if(A[ans[0]][0]!=mn){
		 cout<<-1<<endl;
		 return;
	 }
	 f(A[ans[0]][0],ans[0]);
	 for(auto it: res) cout<<it<<' ';
}
main(){
	ios;
	int T=1;
	//cin>>T;
	for(int i=1;i<=T;i++){
		//cout<<"Case #"<<i<<": ";
		solve();
	}
}


