#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
using ll = long long int;
#define F first
#define S second
#define fast_io ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int N=2e5+10,LN=20,SQ=550,M=5e4+10;
const ll INF=1e18;
const int MOD=1000000007 /*998244353*/;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using pll=pair<ll,ll>;
using pii=pair<int,int>;
#define ordered_set tree<pair<pll,ll>, null_type,less<pair<pll,ll>>, rb_tree_tag,tree_order_statistics_node_update>
ll pow(ll x, ll y, ll mod){
    ll ans=1;
    while (y != 0) {
        if (y & 1) ans = ans * x % mod;
        y >>= 1;
        x = x * x % mod;
    }
    return ans;
}
ll n,a[N],p[N],f[N],inv;
vector<ll> ans;
void update(ll t, ll x){
    while(t<N) f[t]+=x,t+=t&-t;
}
ll get(ll t, ll x=0){
    while(t) x+=f[t],t-=t&-t;
    return x;
}
int main(){
    fast_io;
    cin >> n;
    for(ll i=1; i<=n; i++){
        cin >> a[i];
        p[a[i]]=i;
        inv+=get(n)-get(a[i]);
        update(a[i],1);
    }
    //cout << inv << '\n';
    if(inv!=n-1) return cout << -1, 0;
    for(ll i=1; i<=n; i++){
        for(ll j=p[i]-1; j>=i; j--){
            //cout << "SALAM" << endl;
            ans.push_back(j);
            swap(p[a[j]],p[a[j+1]]);
            swap(a[j],a[j+1]);
        }
    }
    for(ll i : ans) cout << i << '\n';
    return 0;
}

/*
    Author: Arjan Singh Bal, IIIT Gwalior
    "Everything in this world is magic, except to the magician"
*/

#include						<bits/stdc++.h>
#ifdef LOCAL
#include						"pprint.hpp"
#else
#define trace 					//
#endif

using namespace std;

template <typename Arg1>
void prn(Arg1&& arg1)
{ cout << arg1 << "\n"; }
template <typename Arg1, typename... Args>
void prn(Arg1&& arg1, Args&&... args)
{ cout << arg1 << " "; prn(args...); }

template <typename Arg1>
void prs(Arg1&& arg1)
{ cout << arg1 << " ";}
template <typename Arg1, typename... Args>
void prs(Arg1&& arg1, Args&&... args)
{ cout << arg1 << " "; prs(args...); }

template <typename Arg1>
void read(Arg1&& arg1)
{ cin >> arg1; }
template <typename Arg1, typename... Args>
void read(Arg1&& arg1, Args&&... args)
{ cin >> arg1; read(args...); }

#define ll						long long
#define pii						pair<int, int>
#define pli						pair<ll, int>
#define pil						pair<int, ll>
#define pll						pair<ll, ll>
#define vi						vector<int>
#define vll						vector<ll>
#define vb						vector<bool>
#define vd						vector<double>
#define vs						vector<string>
#define ff						first
#define ss						second
#define pb						push_back
#define eb						emplace_back
#define ppb						pop_back
#define pf						push_front
#define ppf						pop_front
#define vpii					vector<pii>
#define umap					unordered_map
#define all(x)					x.begin(),x.end()
#define clr(a,b)				memset(a,b,sizeof a)
#define fr(i, n)				for (int i = 0; i < n; ++i)
#define fr1(i, n)				for (int i = 1; i <= n; ++i)
#define rfr(i, n)				for (int i = n - 1; i >= 0; --i)
#define precise(x)				cout << fixed << setprecision(x)
typedef double					f80;

inline void solve();

signed main()
{
#ifdef LOCAL
    freopen("in.txt" , "r" , stdin);
    //freopen("out.txt" , "w" , stdout);
#else	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#endif
    
    int t = 1;
    // read(t);
    fr1 (tc, t) {
        // cout << "Case #" << tc << ": ";
        solve();
    }
    return 0;
}



inline void solve()
{
    int n;
    read(n);
    vi vec(n);
    
    fr (i, n) {
        read(vec[i]);
    }

    vb usd(n - 1, 0);
    set<pii> remain;

    fr (i, n - 1) {
        remain.insert({vec[i + 1] - vec[i], i});
    }

    vi ans;

    while (!remain.empty()) {
        pii cur = *remain.begin();
        remain.erase(cur);
        if (cur.ff > 0) {
            prn(-1);
            return ;
        }
        int idx = cur.ss;
        usd[idx] = 1;
        ans.pb(idx);
        if (idx && !usd[idx - 1]) {
            remain.erase({vec[idx] - vec[idx - 1], idx - 1});
        }
        if (idx + 1 < n - 1 && !usd[idx + 1]) {
            remain.erase({vec[idx + 2] - vec[idx + 1], idx + 1});
        } 
        swap(vec[idx], vec[idx + 1]);
        if (idx && !usd[idx - 1]) {
            remain.insert({vec[idx] - vec[idx - 1], idx - 1});
        }
        if (idx + 1 < n - 1 && !usd[idx + 1]) {
            remain.insert({vec[idx + 2] - vec[idx + 1], idx + 1});
        }
    }

    trace(vec);

    fr (i, n) {
        if (vec[i] != i + 1) {
            prn(-1);
            return ;
        }
    }

    for (auto i : ans) {
        prn(i + 1);
    }
}
