#include <iostream>
#include <queue>
#include <utility>
using namespace std;

int main() {
  int N; cin >> N;
  int P[N];
  for (int i = 0; i < N; i++) cin >> P[i];
  
  bool flag = true;
  bool flag_[N - 1];
  for (int i = 0; i < N - 1; i++) flag_[i] = false;
  int now = 0;
  queue<int> Que;
  
  for (int i = 0; i < N; i++){
    if (i == P[i] - 1) flag = false;
    if (i > P[i] - 1){
      for (int j = i - 1; j >= now; j--){
        if (P[j + 1] < P[j] && flag_[j] == false){
          flag_[j] = true;
          Que.push(j);
          swap(P[j], P[j + 1]);
        }
      }
      now = i;
    }
  }
  
  for (int i = 0; i < N - 1; i++){
    if (flag_[i] == false) flag = false;
  }
  for (int i = 0; i < N; i++){
    if (i != P[i] - 1) flag = false;
  }
  
  if (flag == true) {
    for (int i = 0; i < N - 1; i++){
      cout << Que.front() + 1 << endl;
      Que.pop();
    }
  }
  else cout << -1 << endl;
}
#include<vector>
#include<cstdio>
using namespace std;
int n,per[200010],ori[200010],mn=1e9;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)	scanf("%d",&per[i]),ori[per[i]]=i;
	vector<int> ans;
	for(int i=n;i;--i)
	{
		if((ori[i]^i)&&mn>ori[i])
		{
			mn=ori[i];
			for(int j=ori[i];j<i;++j)	ans.push_back(j),(per[j]^=per[j+1]^=per[j]^=per[j+1]);
		}
	}
	if(ans.size()^int(n-1))	printf("-1\n");
	else
	{
		for(int i=1;i<=n;++i)	if(per[i]^i)	return printf("-1\n"),0;
		for(int now : ans)	printf("%d\n",now);
	}
	return 0;
}