#include<bits/stdc++.h>
using namespace std;
int a[200005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n,i,j;
    cin >> n;
    for(i=1;i<=n;i++)
        cin >> a[i];

    int last = 1;
    vector<int>ans;
    for(i=2;i<=n;i++)
    {
        if(a[i] < i)
        {
            if(a[i] < last)
            {
                cout << -1 << endl;
                return 0;
            }
            int pos = a[i];
            for(j=i;j>pos;j--)
            {
                swap(a[j],a[j-1]);
                ans.push_back(j-1);
            }
            last = i;
        }
    }
    if(ans.size() != (n-1)) cout << -1 << endl;
    else
    {
        for(i=1;i<=n;i++)
        {
            if(a[i] != i)
            {
                cout << -1 << endl;
                return 0;
            }
        }
        for(int x:ans) cout << x << endl;
    }
}

#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int a[n];
	for (auto &i : a) i = ri() - 1;
	
	int plus[n];
	int minus[n];
	memset(plus, 0, sizeof(plus));
	memset(minus, 0, sizeof(minus));
	for (int i = 0; i < n; i++) {
		if (a[i] < i) {
			plus[a[i]]++;
			plus[i]--;
		} else if (a[i] > i) {
			minus[i]++;
			minus[a[i]]--;
		}
	}
	for (int i = 0; i + 1 < n; i++) plus[i + 1] += plus[i], minus[i + 1] += minus[i];
	
	bool ok = true;
	for (int i = 0; i + 1 < n; i++) if (plus[i] != 1 || minus[i] != 1) ok = false;
	if (!ok) {
		puts("-1");
		return 0;
	}
	
	for (int i = 0; i < n; i++) {
		if (a[i] < i) {
			for (int j = a[i]; j < i; j++) plus[j] = a[i];
		} else if (a[i] > i) {
			for (int j = i; j < a[i]; j++) minus[j] = a[i];
		}
	}
	std::set<int> avail;
	auto update = [&] (int i) {
		if (a[i] == minus[i] && a[i + 1] == plus[i]) {
			avail.insert(i);
		} else avail.erase(i);
	};
	for (int i = 0; i + 1 < n; i++) update(i);
	
	std::vector<int> res;
	while (avail.size()) {
		int cur = *avail.begin();
		res.push_back(cur);
		avail.erase(avail.begin());
		std::swap(a[cur], a[cur + 1]);
		if (cur) update(cur - 1);
		update(cur);
		if (cur + 1 < n - 1) update(cur + 1);
	}
	if ((int) res.size() != n - 1) {
		puts("-1");
		return 0;
	}
	
	for (auto i : res) printf("%d\n", i + 1);
	return 0;
}
