#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define pb push_back
#define ss second
#define ff first
#define vt vector
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
const ll inf = 1e16;
const int mod = 1e9+7;
const int maxn = 2e5 + 12;
int k = 0, p;
map<int, int> m;
vi t[20];
queue<pii> wt[20];
int out[maxn], cmp[maxn * 4], gr[maxn * 4];
void go(int v, int l, int r, int cnt) {
	if(l + 1 == r) {
		wt[cnt].push({v, l});
		return;
	}
	go(v * 2 + 1, l, (l + r) / 2, cnt + 1);
	go(v * 2 + 2, (l + r) / 2, r, 1);
	cmp[v] = cmp[v * 2 + 1];
}
void check(int v, int l, int r) {
	if(l + 1 == r)return;
	check(v * 2 + 1, l, (l + r) / 2);
	check(v * 2 + 2, (l + r) / 2, r);	
	if(gr[v * 2 + 2] < gr[v * 2 + 1]) {
		//cout << gr[v * 2 + 2] << ' ' << gr[v * 2 + 1] << ' ' << v;
		cout << "-1";
		exit(0);
	}
}
void solve() {
	int n;
	cin >> n;
	p = (n + 1) / 2;
	while(p) p /= 2, k++;
	int a[n];
	p = (n + 1) / 2;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		m[a[i]]++;
	}
	sort(a, a + n);
	for(auto i : m) {
		if(i.ss > k) {
			cout << "-1";
			return;
		}
		t[i.ss].pb(i.ff);
	}
	go(0, 0, p, 1);
	for(int i = 0; i < n; i++) {
		if(i == 0 || a[i] != a[i - 1]) {
			int x = m[a[i]];
			if(wt[x].empty()) {
				cout << "-1";
				return;
			}
			pii now = wt[x].front();
			wt[x].pop();
			out[now.ss] = a[i];
			while(1) {
				if(cmp[now.ff] != x)break;
				gr[now.ff] = x;
				if(now.ff == 0)break;
				now.ff = (now.ff - 1) / 2;
			}
		}
	}
	check(0, 0, p);
	for(int i = 0; i < p; i++) {
		cout << out[i] << ' ';
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int times = 1;
	//cin >> times;
	for(int i = 1; i <= times; i++) {
		solve();
	}
	return 0;
}
