#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 pii pair <ll, ll>
#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], place[N];
ll check[N], ans[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, -1LL);
	}
	ll fd(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){
			tree[x] = true;
			cnt = 1;
		}
		if(i < mid) return cnt + fd(i, 2 * x + 1, l, mid);
		else return cnt + fd(i, 2 * x + 2, mid, r);
	}
	ll fd(ll i){
		return fd(i, 0, 0, sz);
	}
};
int main() {
	ios::sync_with_stdio(false);
  	cin.tie(NULL);
  	ll n, mx = 0;
  	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);
  		check[cnt[i]]++;
  	}
  	if(sz != (n + 1) / 2){
  		cout << -1;
  		return 0;
  	}
  	segtree obj;
  	obj.init((n + 1) / 2);
  	for(ll i = 0; i < (n + 1) / 2; i++){
  		place[i] = obj.fd(i);
  		mx = max(mx, place[i]);
  		if(check[place[i]] == 0){
  			cout << -1;
  			return 0;
  		}
  		check[place[i]]--;
  	}
  	for(ll i = mx; i >= 1; i--){
  		vector <pii> vec;
  		for(ll j = 0; j < sz; j++){
  			if(place[j] == i){
  				if(j == 0) vec.pb({0, j});
  				else vec.pb({ans[j - 1], j});
  			}
  		}
  		sort(vec.begin(), vec.end());
  		sort(q[i].begin(), q[i].end());
  		for(ll j = 0; j < (ll)vec.size(); j++){
  			if(vec[j].F > q[i][j]){
  				cout << -1;
  				return 0;
  			}
  			ans[vec[j].S] = q[i][j];
  		}
  	}
  	for(ll i = 0; i < sz; i++){
  		cout << b[ans[i]] << " ";
  	}
  return 0;
}
// equal, min, max, 1, random
/*

*/
