#include <bits/stdc++.h>
#define ll long long
#define all(a) a.begin(), a.end()
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define ull unsigned long long
#define ld long double
#define files freopen("HelpMe.in", "r", stdin), freopen("HelpMe.out", "w", stdout)
using namespace std;
const ll mod = 1e9+7;
const ll N = 2e5 + 10;
const ll M = 50 + 10;
const ll P = 337ll;
const ld EPS = 1e-9;
const ll block = 400;
ll arr[N], b[N], cnt[N], cnt2[N];
vector <ll> q[M];
struct segtree {
	vector <bool> tree;
	vector <ll> mn;
	ll sz;
	void init(ll n){
		sz = n;
		tree.assign(2 * sz - 1, false);
		mn.assign(2 * sz - 1, LLONG_MAX);
	}
	ll find(ll i, ll x, ll l, ll r){
		if(r - l == 1) return 1LL;
		ll mid = (r + l) / 2, cnt = 0;
		if(tree[x] == false){
			cnt++;
			tree[x] = true;
		}
		if(i < mid) return cnt + find(i, 2 * x + 1, l, mid);
		else return cnt + find(i, 2 * x + 2, mid, r);
	}
	ll find(ll i){
		return find(i, 0, 0, sz);
	}
	void upd(ll i, ll v, ll x, ll l, ll r){
		if(r - l == 1){
			mn[x] = v;
			return;
		}
		ll mid = (r + l) / 2;
		if(i < mid) upd(i, v, 2 * x + 1, l, mid);
		else upd(i, v, 2 * x + 2, mid, r);
		mn[x] = min(mn[2 * x + 1], mn[2 * x + 2]);
	}
	void upd(ll i, ll v){
		return upd(i, v, 0, 0, sz);
	}
	void check(){
		for(ll i = 0; i < 2 * sz - 1; i++){
			cnt2[mn[i]]++;
			//cout << mn[i] << " ";
		}
	}
};
int main() {
	ios::sync_with_stdio(false);
  	cin.tie(NULL);
  	ll n;
  	cin >> n;
  	for(ll i = 0; i < n; i++){
  		cin >> arr[i];
  		b[i] = arr[i];
  	}
  	sort(b, b + n);
  	ll sz = unique(b, b + n) - b;
  	for(ll i = 0; i < n; i++){
  		arr[i] = lower_bound(b, b + sz, arr[i]) - b;
  		cnt[arr[i]]++;
  	}
	for(ll i = 0; i < sz; i++){
        if(cnt[i] > 20){
            cout << -1;
            return 0;
        }
  		q[cnt[i]].pb(i);
  	}
  	for(ll i = 1; i <= 20; i++){
  		sort(q[i].begin(), q[i].end());
  	}
  	if(sz != (n + 1) / 2){
  		cout << -1;
  		return 0;
  	}
  	segtree obj;
  	obj.init((n + 1) / 2);
  	for(ll i = 0, k; i < (n + 1) / 2; i++){
  		k = obj.find(i);
  		if((ll)q[k].size() == 0){
  			cout << -1;
  			return 0;
  		}
  		obj.upd(i, q[k][0]);
  		q[k].erase(q[k].begin());
  	}
  	obj.check();
  	for(ll i = 0; i < n; i++){
  		if(cnt[i] != cnt2[i]){
  			cout << -1;
  			return 0;
  		}
  	}
  	for(ll i = (n + 1) / 2 - 1; i < n; i++){
  		cout << b[obj.mn[i]] << " ";
  	}
  return 0;
}
// equal, min, max, 1, random
/*

*/
