#include <bits/stdc++.h>
using namespace std;


//#define int long long 

const int N = 2e5 + 7;

int p[N], r[N], t[N];


vector <int> ans;


int apply(int x) {
    if(r[x] == x) return 0;
    if(t[r[x] - 1]) return -1;
    int ax = p[r[x]], ay = p[r[x] - 1];
    t[r[x] - 1] = true;
    ans.push_back(r[x] - 1);
    swap(p[r[x]], p[r[x] - 1]);
    swap(r[ax], r[ay]);
    return 1;
}

int32_t main() {
    ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n; cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> p[i];
        r[p[i]] = i;
    }

    for(int i = 1; i <= n; i++) {
        while(true) {
            int x = apply(i);
            if(x < 0) {
                cout << -1 << endl;
                return 0;
            }
            if(!x) break;
        }
    }
    if(ans.size() != n - 1) {
        cout << -1 << endl;
        return 0;
    }
    for(int x: ans) cout << x << endl;
}

#include "bits/stdc++.h"
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
//#define pi 3.141592653589793238462643383279502
#define M  998244353
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1000000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define endl "\n"
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
struct FenwickTree {
	std::vector<int> f, cnt;
	int n;
	FenwickTree(int _n) {
		n = _n; f.resize(n+10), cnt.resize(n+10);
	}
	void update(int i, int x) {
		while(i <= n) {
			cnt[i] += x, i += i&(-i);
		}
	}

	int sum(int i) {
		int ans = 0;
		while(i > 0) {
			ans += cnt[i], i -= i&(-i);
		}
		return ans;
	}
	int sum(int l, int r) {
		return sum(r)-sum(l-1);
	}

	void update_xor(int i, int x) {
		while(i <= n) {
			f[i] ^= x, i += i&(-i);
		}
	}
	int Xor(int i) {
		int ans = 0;
		while(i > 0) {
			ans ^= f[i], i -= i&(-i);
		}
		return ans;
	}
	int Xor(int l, int r) {
		return Xor(r)^Xor(l-1);
	}
}ft(N);
void solve()
{
    int n;
    cin>>n;
    vi a(n);
    rep(i,0,n)cin>>a[i];
    for(int i=0;i<n;i++)
    {
        if(a[i]==(i+1))
        {
            cout<<-1<<endl;
            return;
        }
    }
    int inv=0;
    vector<pii>res;
    for(int i=(n-1);i>=0;i--)
    {   int ad=ft.sum(a[i]-1);
        inv+=ad;
        res.pb({i,ad});
        ft.update(a[i],1);
    }
    if(inv!=(n-1))
    {
        cout<<-1<<endl;
        return;
    }
    else
    {
        for(auto x:res)
        {
            for(int j=x.F;j<(x.F+x.S);j++)
                cout<<(j+1)<<endl;
        }
    }

}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int t;
   t=1;
   for(int i=0;i<t;i++)
   {
       solve();
   }
}
