#include<bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long long n , a [200005] , num , did [200005] , f = 1;
set < pair < int , int > > s;
vector < int > v;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    cin >> n;
    for ( int i = 1 ; i <= n ; i ++ )
    {
        cin >> a [i];
        s . insert ( { a [i] , i } );
    }
    while ( s . size () )
    {
        pair < int , int > p = * -- s . end ();
        s . erase ( -- s . end () );
        int x = p . first , y = p . second;
        if ( x == y ) continue;
        num ++;
        if ( x > y )
        {
            if ( did [y] )
            {
                f = 0;
                break;
            }
            did [y] = 1;
            s . erase ( s . lower_bound ( { a [ y + 1 ] , y + 1 } ) );
            swap ( a [y] , a [ y + 1 ] );
            s . insert ( { a [y] , y } );
            s . insert ( { a [ y + 1 ] , y + 1 } );
            v . push_back ( y );
        }
        else
        {
            if ( did [ y - 1 ] )
            {
                f = 0;
                break;
            }
            did [ y - 1 ] = 1;
            s . erase ( s . lower_bound ( { a [ y - 1 ] , y - 1 } ) );
            swap ( a [y] , a [ y - 1 ] );
            s . insert ( { a [y] , y } );
            s . insert ( { a [ y - 1 ] , y - 1 } );
            v . push_back ( y - 1 );
        }
    }
    if ( f == 0 )
    {
        cout << -1;
        return 0;
    }
    if ( v . size () == n - 1 ) for ( int i = 0 ; i < v . size () ; i ++ ) cout << v [i] << endl;
    else cout << -1;
}

#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

class BIT{
public:
  ll n,bit[555555];
  BIT(){fill(bit,bit+555555,0);}
  void add(ll i,ll x){
    while(i<=n){
      bit[i]+=x;
      i+=i&-i;
    }
  }
  ll sum(ll i){
    ll s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }
};

BIT b=BIT();

void Main() {
  ll n;
  R n;
  vector<ll> a(n);
  rep(i,n) R a[i];
  {
    b.n=n+1;
    ll ans=0;
    rep(i,n) {
      b.add(a[i],1);
      ans+=b.sum(n+1)-b.sum(a[i]);
    }
    if(ans!=n-1) {
      pr(-1);
      return;
    }
  }
  rep(i,n) a[i]--;
  ll c[n];
  rep(i,n) c[a[i]]=i;
  vector<ll> v;
  rep(i,n) {
    while(c[i]!=i) {
      v.pb(c[i]);
      ll x=a[c[i]],y=a[c[i]-1];
      swap(a[c[i]],a[c[i]-1]);
      c[x]--;
      c[y]++;
    }
  }
  rep(i,v.size()) pr(v[i]);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}
