#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n; scanf("%d",&n);
	vector<int> p(n);
	rep(i,n) scanf("%d",&p[i]), p[i]--;

	vector<int> pos(n);
	rep(i,n) pos[p[i]]=i;

	vector<int> ans;
	vector<bool> used(n-1);
	rep(x,n){
		int i=pos[x];
		while(x<i){
			if(used[i-1]){
				puts("-1");
				return 0;
			}
			used[i-1]=true;
			pos[p[i]]=i-1;
			pos[p[i-1]]=i;
			swap(p[i-1],p[i]);
			ans.emplace_back(i-1);
			i--;
		}
	}

	if(ans.size()==n-1){
		rep(i,n-1) printf("%d\n",ans[i]+1);
	}
	else{
		puts("-1");
	}

	return 0;
}


#include <bits/stdc++.h>
   
#define f(i,a,b) for( ll i = a; i < b ; i++ )
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair 
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)
#define watch(x) cout << (#x) << " is " << (x) <<"\n"
#define test ll t;cin>>t;while(t--)
#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
const ll mod = 1e9+7;
const ll MAX = 2e5+100;
const ll inf = 1e9;


ll a[MAX];
int main(){
  fastio; 
  ll n;
  cin>>n;
  f(i,0,n) cin>>a[i];
  f(i,0,n) a[i]--;
  vi v;
  f(i,0,n){
    if(a[i]==i) continue;
    f(j,i+1,n){
      if(a[j]==i){
        af(k,j,i+1){
          swap(a[k-1],a[k]);
          v.pb(k);
        }
        i = j-1;
        break;
      }
    }
  }
  bool go = true;
  f(i,0,n){
    if(a[i]!=i) go = 0;
  }
  if(sz(v)!=n-1) go = false;
  if(!go){
    cout<<"-1\n";
    return 0;
  }
  for(auto it : v) cout<<it<<"\n";
  return 0;  
  }   