#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<complex>
#include<cstdio>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
#define removeduplicates(vec) vec.erase( unique( vec.begin(), vec.end() ), vec.end() )
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
vector<int>res;
int a[N];
int n;
void rec(int l,int r,int ch){
	if(ch)
	for(int i=r-1;i>=l;i--){
		if(a[i]>a[i+1]){
			swap(a[i],a[i+1]);
			res.pb(i+1);
			rec(l,i,1);
			rec(i+1,r,0);
			return;
		}
	}
	else
	for(int i=l;i<r;i++){
		if(a[i]>a[i+1]){
			swap(a[i],a[i+1]);
			res.pb(i+1);
			rec(l,i,1);
			rec(i+1,r,0);
			return;
		}
	}
}
void solve(){
	cin>>n;
	rep(i,n)cin>>a[i];
	//int mk[n-1]={0};
	//int c=0;
	/*for(int i=0;i<n;i++){
		for(int j=0;j+1<n;j++){
			if(a[j]>a[j+1]){
				if(mk[j]){cout<<-1;return;}
				res.pb(j+1);
				mk[j]=1;
				swap(a[j],a[j+1]);
				c++;
			}
		}
		if(c==n-1)break;
	}*/
	rec(0,n-1,0);
	for(int i=0;i+1<n;i++)if(a[i]>a[i+1]){cout<<-1;return;}
	if(res.size()<n-1){cout<<-1;return;}
	for(int i:res)cout<<i<<"\n";
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}
#pragma GCC optimize ("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define FORD(i, a, b) for (int i=(a); i>(b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (63 - __builtin_clzll(x))
#define SZ(x) ((int)(x).size())
#define HASK(S, x) (S.find(x) != S.end())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std; 
 
const int maxN = 1 << 19;

int P[maxN], R[maxN];
bool juz[maxN];
vector <int> res;

void click(int i)
{
	swap(P[i], P[i+1]);
	swap(R[P[i]], R[P[i+1]]);
	juz[i] = true;
	res.pb(i);	
}	

void fail()
{	printf("-1\n"); exit(0);	}

void solve()
{
	int n;
	scanf ("%d", &n);
	
	
	FOR(i, 1, n+1)
	{
		scanf ("%d", P+i);
		R[P[i]] = i;
	}
	
	FORD(i, n, 1)
	{
		if (R[i] == i and (!juz[i-1] or !juz[i]))	fail();
		while (R[i] != i)
		{
			if (juz[R[i]])	fail();
			click(R[i]);
		}
	}
	
	for (int i : res)
		printf("%d\n", i);
}
 
int main()
{
	int t = 1;
	//scanf ("%d", &t);
	FOR(tid, 1, t+1)
	{
		//printf("Case #%d: ", tid);
		solve();
	}
	return 0;
}
