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

mt19937_64 llrand((int) chrono::steady_clock::now().time_since_epoch().count());

#define st first
#define nd second
#define pb push_back

#ifndef ONLINE_JUDGE
  #define db(x) cerr << #x << " == " << x << endl
  #define dbs(x) cerr << x << endl
  #define _ << ", " <<
#else
  #define db(x) ((void)0)
  #define dbs(x) ((void)0)
#endif

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;

const int INF = 0x3f3f3f3f, MOD = 1e9+7;
const int N = 2e5+5;

int n;
bool used[N];
int pos[N];
int a[N];

vector<int> ans;

bool prob;

void change(int i, int j) {
  swap(a[i], a[j]);
  swap(pos[a[i]], pos[a[j]]);
  used[i] = true;
  ans.push_back(i);
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for(int i = 1; i <= n; i++) {
    cin >> a[i];
    pos[a[i]] = i;
  }

  for(int i = 1; i <= n; i++) {
    while(pos[i] != i) {
      if(used[pos[i] - 1]) {
        prob = true;
        break;
      }
      change(pos[i] - 1, pos[i]);
    }

    if(prob) break;
  }

  for(int i = 1; i < n; i++) if(!used[i]) prob = true;

  if(prob) cout << -1 << "\n";
  else {
    for(auto x : ans) cout << x << "\n";
  }
}


#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>
//#include<atcoder/all>


using namespace std;
//using namespace atcoder;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.12f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 1010101;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// mod.m での a の逆元 a^ { -1 } を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//union-find木について
//サイズによる更新をしている
ll par[201010];
ll rank2[201010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 1;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
		rank2[y] += rank2[x];
	}
	else {
		par[y] = x;
		rank2[x] += rank2[y];
	}
}


ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n), p(n), ans;
	rep(i, n) {
		cin >> a[i];
		a[i]--;
		p[a[i]] = i;
	}
	rep(i, n) {
		for (ll j = p[i];j > i;j--) {
			swap(a[j], a[j - 1]);
			ans.push_back(j);
			p[a[j - 1]]++;
		}
		if (ans.size() >= n) {
			cout << -1 << endl;
			return 0;
		}
	}
	rep(i, n) {
		if (a[i] != i) {
			cout << -1 << endl;
			return 0;
		}
	}
	if (ans.size() != n - 1) {
		cout << -1 << endl;
		return 0;
	}
	rep(i, n - 1) {
		cout << ans[i] << endl;
	}
	return 0;
}