#include <bits/stdc++.h>
#define int long long
using namespace std;
int i, j, kek, u[12][12];
char a[69][69];
pair<int, int> d[] = {{-1, 0}, {0, -1}, {0, 1}, {1, 0}};
vector<pair<int, int>> comp;

void dfs(int x, int y) {
	u[x][y] = 1;
	comp.push_back({x, y});
	for (int dir = 0; dir < 4; dir++) {
		int nx = x + d[dir].first, ny = y + d[dir].second;
		if (nx < 0 || ny < 0 || nx >= 10 || ny >= 10) continue;
		if (a[nx][ny] == '.') continue;
		if (!u[nx][ny]) dfs(nx, ny);
	}
}
map<int,int>cnt;
map<int,multiset<int>>l;
int b[200005];
void build(int d,int mn,int tl,int tr){
	// cout<<d<<endl;
	if(tl==tr){
		b[tl]=mn;
		return;
	}else{
		int tm=(tl+tr)>>1;
		build(d-1,mn,tl,tm);
		if(l[d-1].empty() or *l[d-1].rbegin()<mn){
			cout<<"-1";exit(0);
		}
		int u=*l[d-1].lower_bound(mn);
		// cout<<mn<<' '<<u<<endl;
		l[d-1].erase(l[d-1].find(u));
		build(d-1,u,tm+1,tr);
	}
}
signed main() {
    cin.tie(0)->sync_with_stdio(0);
	int n;
	cin>>n;
	int mn=INT_MAX;
	for(int i=1;i<=n;i++){
		int a;
		cin>>a;
		cnt[a]++;
		mn=min(mn,a);
	}
	for(auto u:cnt){
		l[u.second].insert(u.first);
	}
	build((int)log2(n+1),mn,1,(n+1)/2);
	if(cnt.size()!=(n+1)/2){
		cout<<-1;exit(0);
	}
	for(int i=1;i<=(n+1)/2;i++){
		cout<<b[i]<<' ';
	}
}

/*
#.#.#.....
.......##.
.#..#.....
.#........
.#..##....
..........
####...#..
.......#..
.......#..
##........
*/