#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define nl cout<<endl

#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define ff first
#define ss second
#define hell 1000000007

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;
#define N 300009

ll power(ll a,ll b,ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
int main()
{	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
        
	ll n;cin>>n;
	ll a[n+2];
	ll pos[n+2];
	vi ans;
	rep(i,1,n+1) {
		cin>> a[i];
		pos[a[i]] = i;
	}


	ll curr = 1;
	ll moves = 0 ;
	while(curr <= n) {
		if(pos[curr] == curr) {
			curr ++;
			continue;
		}

		// bring it to the correct position
		moves += pos[curr] - curr;
		if( moves >= n) {
			break;
		}

		for(ll i=pos[curr]-1;i>=curr;i--) {
			swap(a[i],a[i+1]);
			pos[a[i]] = i;
			pos[a[i+1]] = i+1;
			ans.pb(i);
		}
		curr ++ ;
	}
	if( ans.size() != n-1) {
		cout << -1 << endl;
		return 0;
	}
	rep(i,1,n+1) {
		if(a[i] != i) {
			cout << -1 << endl;
			return 0;
		}
	}
	for(auto it: ans) {
		cout << it <<endl;
	}
}
#include <bits/stdc++.h>
using namespace std;

int main(){
  int N;
  cin >> N;
  int P;
  vector<int> pos(N+1),ans;
  for(int i=1;i<=N;i++){
    cin >> P;
    pos.at(P)=i;
  }
  for(int i=pos.at(1)-1;i>=1;i--){
    ans.emplace_back(i);
  }
  int ma=pos.at(1);
  for(int i=2;i<=N;i++){
    if(pos.at(i)<i){
    }else if(ma<=i){
      for(int j=pos.at(i)-1;j>=i;j--){
        ans.emplace_back(j);
      }
    }else{
      cout << -1 << endl;
      return 0;
    }
    ma=max(ma,pos.at(i));
  }
  if(ans.size()==N-1){
    for(int i=0;i<ans.size();i++){
      cout << ans.at(i) << endl;
    }
  }else{
    cout << -1 << endl;
  }
  return 0;
}
