#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("sse,sse2,sse3,sse4,sse4.1,sse4.2,abm,bmi,bmi2,popcnt,lzcnt,avx,avx2,fma")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <time.h>
#include <deque>
#define ll long long
#define t_c_b ios_base::sync_with_stdio (0);cin.tie (0);cout.tie (0);long long n;cin >> n;vector <int> g (n);for (long long i = 0; i < n; i++) {cin >> g[i];}
using namespace std;
using loh = long long; // loh
using flag = bool;
using lohd = long double; // short (4bite) // dolik loh
vector <pair <loh, loh>> vc; loh n, started = 0;
vector <loh> G; flag reality = true;

bool comporator (pair <int, int> a, pair <int, int> b) {
	if (a.second < b.second) {
		return false;
	}
	else if (a.second == b.second && a.first > b.first) {
		return false;
	}
	return true;
}

void create (loh layer) {
	if (layer > n) {
		return;
	}
	loh xod = layer / 2, putb = 0;
	for (loh i = 0; i < layer; i++) {
		if (putb >= layer) {
			putb = 0;
			xod /= 2;
		}
		if (vc[i].second == 0) {
			reality = false;
			return;
		}
		else if (G[started+putb] == 0){
			G[started + putb] = vc[i].first;
			vc[i].second--;
		}
		else if (G[started + putb] != 0) {
			i--;
		}
		putb += xod;
	}
	started += layer;
	create (layer * 2);
}

int main () {
	/*
	t_c_b;
	vector <pair <int, int> > G;
	multiset <int> Set;
	for (int i = 0; i < n; ++i) {
		Set.insert (g[i]);
	%>
	while (!Set.empty ()) {
		G.push_back ({ Set.count (*Set.begin ()), *Set.begin () });
		Set.erase (*Set.begin ());
	}
	sort (G.begin (), G.end (), comporator);
	if (G[0].first > n/2) {
		cout << -1; return 0;
	}
	vector <int> tree (n);
	ll itter = 1;
	for (int i = 0; i < n; ++i) {
		if (i == 0) {
			tree[0] = G[0].second;
		}
		else {
			if (i&1) {
				tree[i] = tree[i / 2];
			}
			else {
				if (itter == G.size ()) {
					cout << -1;
					return 0;
				}
				tree[i] = G[itter].second;

				itter++;
			}
		}
	}
	vector <int> tree_copy = tree;
	sort (tree_copy.begin (), tree_copy.end ());
	sort (g.begin (), g.end ());
	if (g != tree_copy){
		cout << -1;
		return 0;
	}
	for (int i = 1; i < n; ++i) {
		if (i & 1) {
			if (tree[i / 2] != min (tree[i], tree[i + 1]) || tree[i]==tree[i+1]) {
				cout << -1;
				return 0;
			}
		}
		else {
			i--;
			if (tree[i / 2] != min (tree[i], tree[i + 1]) || tree[i] == tree[i + 1]) {
				cout << -1;
				return 0;
			}
			i++;
		}
	}
	for (int i = n/2; i < n; ++i) {
		cout << tree[i] << " ";
	} */
	cin >> n;
	G.resize (n);
	vector < loh > allchisla (n);
	map <loh, loh> mp;
	for (loh i = 0; i < n; i++) {
		loh x;
		cin >> x;
		allchisla[i] = x;
		mp[x]++;
	}
	for (auto u : mp) {
		vc.push_back (u);
	}
	sort (vc.begin (), vc.end (), comporator);
	if (vc.size () != (n / 2) + 1) {
		cout << -1;
		return 0;
	}
	create (1);
	if (reality == false) {
		cout << -1;
		return 0;
	}
	for (loh i =0; i < n / 2; i++) {
		if (G[i] != min (G[i*2 + 2], G[i * 2 + 1])) {
			cout << -1;
			return 0;
		}
	}
	vector <loh> G2 = G;
	sort (G2.begin (), G2.end ()); sort (allchisla.begin (), allchisla.end ());
	if (G2 != allchisla) {
		cout << -1;
		return 0;
	}
	for (loh i = n / 2; i < n; i++) {
		cout << G[i] << " ";
	}
}