#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int N;
    cin >> N;
    vector<int> P(N);
    for (int i=0; i<N; ++i) cin >> P[i];

    for (int i=0; i<N; ++i) --P[i];
    vector<int> idx(N);
    for (int i=0; i<N; ++i) idx[P[i]] = i;
    vector<int> ans;
    int cur = 0;
    auto sorted = [&P](int s, int t) -> bool {
        for (int i=s; i<t; ++i) {
            if (P[i] != i + 1) return false;
        }
        return true;
    };
    while (cur < N-1) {
        int id = idx[cur];
        if (id == cur) {
            cout << -1 << '\n';
            return;
        } else if (id == cur + 1) {
            ans.push_back(cur);
            ++idx[P[id-1]];
            swap(P[id-1], P[id]);
            cur = id;
        } else {
            if (!sorted(cur, id-1)) {
                cout << -1 << '\n';
                return;
            }
            for (int i=id-1; i>=cur; --i) ans.push_back(i);
            ++idx[P[id-1]];
            swap(P[id-1], P[id]);
            cur = id;
        }
    }
    if ((int)ans.size() != N-1) cout << -1 << '\n';
    else for (int x : ans) cout << x + 1 << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

#include "bits/stdc++.h"
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

long long LLINF = 1e18;
int INF = 1e9+1e6;
#define MAXN (200006)
ll n;
vector<pi> v;
int main() {
	FAST
	cin>>n;
	ll mx = -1;
	FOR(i,1,n) {
		ll a; cin>>a;
		if(mx > i && a >= i) {
			cout<<"-1\n";
			return 0;
		}
		if(a > i) {
			v.eb(i, a);
		}
		mx = max(mx, a);
	}
	reverse(all(v));
	vector<ll> o;
	for(auto i:v) {
		FOR(j,i.f,i.s-1) {
			o.eb(j);
		}
	}
	if(o.size()!=n-1) {
		cout<<"-1\n";
		return 0;
	}
	for(auto i:o) cout<<i<<'\n';
	return 0;
}
