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

int main()
{
	int n;
	cin >> n;
	vector<int> p(n);
	for(int i = 0; i < n; i++) cin >> p[i];
	int l = 0;
	vector<int> ans;
	for(int r = 0; r < n; r++) {
		if(p[l] == l + 1) {
			cout << -1 << endl;
			return 0;
		}
		if(p[r] == l + 1) {
			for(int j = r - 1; j >= l; j--) {
				swap(p[j], p[j + 1]);
				ans.push_back(j + 1);
			}
			for(int j = l; j < r; j++) {
				if(j + 1 != p[j]) {
					cout << -1 << endl;
					return 0;
				}
			}
			l = r;
		}
	}
	for(auto&& e : ans) cout << e << endl;
	return 0;
}
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    ll N;
    cin >> N;
    vector<ll> P(N);
    vector<ll> X(N);
    REP(i,N){
        ll p;
        cin >> p;
        P[i] = p-1;
        X[p-1] = i;
    }

    vector<ll> ans;
    vector<bool> used(N, false);
    bool valid = true;
    REP(i,N){
        ll idx = X[i];
        for(int k = idx; k > i; k--){
            if(used[k-1]){
                valid = false;
                break;
            }
            X[P[k]] = k-1;
            X[P[k-1]] = k;
            swap(P[k], P[k-1]);
            used[k-1] = true;
            ans.push_back(k);
        }

        if(!valid)
            break;
    }

    REP(i,N){
        if(P[i] != i){
            valid = false;
            break;
        }
    }

    if(ans.size() != N-1)
        valid = false;

    if(valid){
        for(auto&& a : ans)
            cout << a << endl;
    }
    else{
        cout << -1 << endl;
    }

    return 0;
}
