#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,a[200005],c[200005],c2[200005],d[200005];
vector<int> g[200005];
void U(int x,int k){
	if(!x)return ;
	while(x<=n)c[x]+=k,x+=x&-x;
}
int Q(int x){
	int r=0;
	while(x)r+=c[x],x-=x&-x;
	return r;
}
void U2(int x,int k){
	if(!x)return ;
	while(x<=n)c2[x]+=k,x+=x&-x;
}
int Q2(int x){
	int r=0;
	while(x)r+=c2[x],x-=x&-x;
	return r;
}
int main(){
	cin>>n;
	ll sum=0;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++){
		if(i==a[i])return puts("-1"),0;
		if(i>a[i]){
			if(a[i]>1){
				U(a[i]-1,1);
				U(a[i],-1);
			}
			//A(a[i],a[i]-1);
			//for(int j=a[i];j<i-1;j++)A(j,j+1);
			//A(i,i-1);
			if(i<a[i]-1)U2(i,1),U2(a[i]-1,-1);
			if(i>1){
				U(i-1,1);
				U(i,-1);
			}
		}
		else {
			if(a[i]>1){
				U2(a[i]-1,1);
				U2(a[i],-1);
			}
			//A(a[i]-1,a[i]);a[i]-1在a[i]之后
			if(i<a[i]-1)U(i,1),U(a[i]-1,-1);
			//for(int j=a[i]-1;j>i;j--)A(j,j-1);
			//A(i-1,i);i-1在i之后 
			if(i>1){
				U2(i-1,1);
				U2(i,-1);
			}
		}
		//for(int i=1;i<=n;i++)cout<<Q(i)<<' '<<Q2(i)<<endl;
		//cout<<endl;
	}
	for(int i=1;i<n-1;i++){
		if(Q(i)&&Q2(i))return puts("-1"),0;
		if(Q(i)==0&&Q2(i)==0)return puts("-1"),0;
		if(Q(i)){
			g[i].push_back(i+1),d[i+1]++;
			//cout<<i<<' '<<i+1<<endl;
		}
		else {
			g[i+1].push_back(i),d[i]++;
			//cout<<i+1<<' '<<i<<endl;
		}
	}
	queue<int> q;
	for(int i=1;i<n;i++)if(!d[i])q.push(i);
	while(!q.empty()){
		int x=q.front();
		q.pop(),printf("%d\n",x);
		for(int i=0;i<g[x].size();i++){
			int y=g[x][i];
			if(!(--d[y]))q.push(y);
		}
	}
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
 
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << (a) << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair
 
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 2e5 + 10;

int n, p[N];
bool vis[N];
vi ans;

void swp(int i) {
    if (vis[i]) {
        cout << "-1\n";
        exit(0);
    }
    vis[i] = 1;
    swap(p[i], p[i+1]);
    ans.pb(i);
}

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

    cin >> n;
    forn(i,n) cin >> p[i];

    for (int i = 1; i < n; i++) {
        int j = i;
        while (j > 0 && p[j] < p[j-1]) {
            swp(j-1);
            --j;
        }
    }
    if (si(ans) != n-1) cout << "-1\n";
    else for (auto x : ans) cout << x+1 << '\n';

    return 0;
}
