#include <bits/stdc++.h>
#define f first
#define s second
#define ll long long
#define pb push_back
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mk make_pair
//#pragma comment(linker, "/stack:2000000")
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;
unordered_set <int> st;
unordered_map <int, int> was;
vector<int> vec;
vector <int> ans;
const int MAXN = 1000000;
int n; int t[MAXN * 4];
int a[MAXN + 1];
int cnt = 0, fx = 0;


void build(vector<int>& h, int v, int l, int r){
    if (l == r){
        t[v] = h[l - 1];
        //cout << "VEC " << h[l - 1] << '\n';
        ans.pb(t[v]);
        was[h[l - 1]]++;
    } else {
        int tm = (l + r) >> 1;
        build(h, v << 1, l, tm);
        build(h, v << 1|1, tm + 1, r);
        if (t[v << 1] < t[v << 1|1]){
            t[v] = t[v << 1];
            was[t[v]]++;
        } else {
            t[v] = t[v << 1|1];
            was[t[v]]++;
        }
        //cout << "VEC " << t[v] << '\n';
    }
}




int main() {
    IOS;
    cin >> n;
    unordered_map<int, int> mp;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        if (st.find(a[i]) == st.end()){
            vec.pb(a[i]);
            st.insert(a[i]);
            mp[a[i]]++;
        } else {
            mp[a[i]]++;
        }
    }
    sort(vec.begin(), vec.end());
    build(vec, 1, 1, vec.size());
    for (int i = 0 ; i < vec.size(); i++){
        if (mp[vec[i]] != was[vec[i]]){
            //cout << "!!! " << mp[vec[i]] << ' ' << was[vec[i]] << ' ' << vec[i] << '\n';
            cout << -1;
            return 0;
        }
    }
    for (int i = 0; i < ans.size(); i++){
        cout << ans[i] << ' ';
    }


}


