#include<iostream>
#include<vector>
#include<string>	
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<cstdio>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

//=================================

ld bpow(ld a, ll n) {
	if (n == 0) {
		return 1;
	}
	if (n % 2 == 0) {
		ld b = bpow(a, n / 2);
		return b * b;
	}
	else {
		return bpow(a, n - 1) * a;
	}
}
//struct seg {
//	ll len, l, r;
//
//	bool operator>(seg other) {
//		return len > other.len;
//	}
//};
//struct segseg {
//	seg l, r;
//};


void solve() {
	/*ll n, k;
	cin >> n >> k;
	vector<int> pos(n);
	int num = 1;
	set<seg> a;
	a.insert({ n * 4, -n * 2, n * 2 });
	vector<segseg> b;
	while (k--) {
		char c;
		cin >> c;
		if (c == '+') {
			seg tt = *a.rbegin();
			a.erase(tt);
			int l = tt.l, r = tt.r, len = tt.len;
			seg t1 = { len / 2, l, (l + r) / 2 };
			seg t2 = {(len + 1) / 2, (l + r) / 2, r};
			pos[num] = t1.r;
			a.insert(t1);
			a.insert(t2);
			b[num] = { t1, t2 };
		}
		else {
			ll t;
			cin >> t;
			segseg tt = b[t];
			seg t1 = b[t].l, t2 = b[t].r;
			a.erase(t1);
			a.erase(t2);
			a.insert({ t1.len + t2.len, t1.l, t2.r });
			b[t1.l]
		}
	}*/
	int m;
	cin >> m;
	int n = (m + 1) / 2;
	vector<int> a(n);
	map<int, int> c;
	for (int i = 0; i < m; ++i) {
		int t;
		cin >> t;
		c[t]++;
	}
	int lg = log2(m + 1);
	vector<set<int>> cn(lg + 1);
	for (auto i : c) {
		if (i.second > lg) {
			cout << -1;
			return;
		}
		cn[i.second].insert(i.first);
	}
	for (int i = 0; i < n; ++i) {
		int ii = n - i;
		int cnt = 1;
		while (ii % 2 == 0) {
			ii /= 2;
			++cnt;
		}
		a[i] = *cn[cnt].begin();
		cn[cnt].erase(cn[cnt].begin());
	}
	for (int j = 1; j < lg; ++j) {
		for (int i = 0; i < n; i += (1 << j)) {
			if (a[i] >= a[i + (1 << (j - 1))]) {
				cout << -1;
				return;
			}
		}
	}
	for (auto i : a) cout << i << ' ';
}

//=================================

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int tt = 1;
	//cin >> tt;
	while (tt--) {
		solve();
		cout << '\n';
	}
	return 0;
}