#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define rreps(i, n, s) for (int i = s; i >= n; i--)

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> p(n);
    map<int, int> m;
    rep(i, n) {
        cin >> p[i];
        p[i]--;
        m[p[i]] = i;
    }
    vector<int> res;
    vector<bool> done(n, false);
    rep(k, n) {
        if (m[k] != k) {
            while (m[k] != k) {
                ll right = m[k];
                ll left = right - 1;
                if (done[left]) break;
                done[left] = true;
                swap(p[right], p[left]);
                m[p[right]] = right;
                m[p[left]] = left;
                res.pb(left);
            }
        }
    }

    bool ok = true;
    rep(i, n - 1) {
        if (p[i + 1] < p[i]) {
            ok = false;
            break;
        }
    }
    if (res.size() != n - 1) { ok = false; }
    if (ok) {
        for (auto idx : res) cout << idx + 1 << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(v) v.begin(),v.end()
constexpr ll MOD=998244353;
constexpr ll INF=1e18;

struct BIT {
	int N;
	VI dat;
	BIT(int N):N(N){
		dat.resize(N+1,0);
	}
	ll sum(int k) {
		k++;
		if(k==0)
			return 0;
		ll res=0;
		for(;k>0;k-=k&-k)
			res+=dat[k];
		return res;
	}
	ll sum(int l, int r){
		return sum(r)-sum(l-1);
	}
	void add(int k, ll x) {
		k++;
		for(;k<=N;k+=k&-k)
			dat[k]+=x;
	}
	int lowerBound(int w) {
		if (w<=0) return 0;
		int x=0;
		int k=1;
		while(k*2<=N) k*=2;
		for(;k>0;k/=2){
			if(x+k<=N&&dat[x+k]<w){
				w-=dat[x+k];
				x+=k;
			}
		}
		return x;
	}
};

int main(){
	int n; cin >> n;
	VI p(n); REP(i,n) cin >> p[i];
	BIT bt(n);
	VI a(n,0);
	REP(i,n){
		a[p[i]-1]=i;
	}
	set<int> st;
	vector<int> ans(0);
	bool no=0;
	for(int i=n-1;i>=0;i--){
		for(int j=a[i]-bt.sum(a[i]);j<i;j++){
			if(st.count(j)){
				no=1;
				break;
			}
			st.insert(j);
			ans.push_back(j);
		}
		bt.add(a[i],1);
	}
	if(no||ans.size()!=n-1)
		cout << -1 << endl;
	else{
		REP(i,n-1)
			cout << ans[i]+1 << endl;
	}
	return 0;
}