#include <bits/stdc++.h>

using namespace std;

#define ff              first
#define ss              second
#define int32			int32_t
#define int             long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pq              priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define mod             1000000007
#define w(x)            int x; cin>>x; while(x--)
#define loop(x, n) for(int x = 0; x < n; x++)

bool sorted(vi &p)
{
	int n = p.size();
	for(int i = 0; i < n - 1; i++)
		if(p[i] > p[i + 1])
			return false;

	return true;
}

int32 main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vi p(n);
	loop(i, n)
		cin >> p[i];

	vi ans;
	set<int> s;
	int swaps = 0;
	for(int i = n - 2; i >= 0; i--)
	{
		int x = i;
		while(x < (n - 1) && p[x] > p[x + 1] && swaps < n)
		{
			swap(p[x], p[x + 1]);
			if(s.find(x) != s.end())
			{
				swaps = n;
				break;
			}
			else
				s.insert(x);
			
			ans.pb(x + 1);
			swaps++;
			x++;
		}
	}

	if(swaps >= n || (n - 1 - swaps))
		cout << -1 << endl;
	else 
	{
		for(int i: ans)
			cout << i << endl;
	}

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int did[202020];
vector<int> ret;

int main() {
    int n;
    cin>>n;
    vector<int> p(n),r(n);
    rep(i,n){
        cin>>p[i];
        p[i]--;
        r[p[i]]=i;
    }

    rep(i,n){
        int x=r[i];
        while(x>i){
            if(did[x-1]==1){
                cout<<-1<<endl;
                return 0;
            }
            did[x-1]=1;
            ret.push_back(x);
            swap(p[x-1],p[x]);
            r[p[x]]=x;
            r[p[x-1]]=x-1;
            x--;
        }
    }
    rep(i,n-1){
        if(did[i]==0){
            cout<<-1<<endl;
            return 0;
        }
    }

    for(auto e : ret) cout<<e<<endl;
}