#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define sz(s) (int)s.size()
#define in insert
#define pii pair<int, int>
#define pb push_back
#define all(x) x.begin(), x.end()
 
const int MAX=4e5+10;
 
int n;
int a[MAX];
int ans[MAX];
set<int> g[MAX];
vector<int> qq;
int t[MAX * 4];

void build(int v, int l, int r){
    if(l == r){
        qq.pb(ans[l]);
        t[v] = ans[l];
        return;
    }
    int mid=(l+r)/2;
    build(v+v, l, mid);
    build(v+v+1, mid+1, r);
    t[v] = min(t[v + v], t[v + v + 1]);
    qq.pb(t[v]);
}

void b1(int v, int l, int r, int k){
    if(l == r){
        ans[l] = t[v];
        return;
    }
    int mid=(l+r)/2;
    t[v + v] = t[v];
    auto it = g[k-1].lower_bound(t[v]);
    if(it == g[k-1].end()){
        t[v + v + 1] = -1;
        return;
    }
    t[v + v + 1] = *it;
    g[k-1].erase(it);
    b1(v+v, l, mid, k-1);
    b1(v+v+1, mid+1, r, k-1);
}
 
int main(){
    cin>>n;
    set<int> st;
    map<int,int> cnt,c;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        cnt[a[i]]++;
        st.in(a[i]);
    }
    for(int x: st){
        g[cnt[x]].in(x);
    }
    int k = 0;
    int x = n;
    while(x){
        k++;
        x /= 2;
    }
    // cout<<k;
    int m = (n + 1) / 2;
    auto it = g[k].begin();
    if(it == g[k].end()){
        cout<< -1;
        return 0;
    }
    t[1] = *it;

    b1(1, 1, m, k);
    // for(int i=1;i<=(n+1)/2;i++)cout<<ans[i]<<" ";
    for(int i=1; i<=m; i++){
        if(ans[i] == -1){
            cout<<-1;
            return 0;
        }
    }
    
    build(1, 1, (n + 1) / 2);
    sort(all(qq));
    sort(a + 1, a + 1 + n);
    if(qq.size() < n){
        cout<<-1;
        return 0;
    }
    for(int i=1; i<=n; i++){
        if(qq[i - 1] != a[i]){
            cout<<-1;
            return 0;
        }
    }
    for(int i=1;i<=(n+1)/2;i++)cout<<ans[i]<<" ";
}