#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<ll>>;

template<class T> bool chmin(T &a, T b) {if(a>b){a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b){a=b;return 1;}return 0;}
#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265358979;



int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    ll n;
    cin >> n;
    vector<ll> p(n);
    vector<ll> diff(n);
    bool zero = true;
    ll abssum = 0;
    for (ll i = 0;i < n;i++){
        cin >> p[i];
        p[i]--;
        diff[i] = (p[i] - i);
        if (diff[i] == 0){
            zero = false;
        }
        abssum += abs(diff[i]);
    }

    if (!zero){
        cout << -1 << endl;
        return 0;
    }
    if (abssum != (n - 1)*2){
        cout << -1 << endl;
        return 0;
    }

    /*for (ll i = 0; i < n; i++){
        cout << diff[i] << " ";
    }
    cout << endl;*/

    vector<bool> seen(n-1,false);
    ll j = 0;
    vector<ll> ans;

    while (ans.size() < n-1){
        while (j < n-1){
            if (diff[j] > 0 && diff[j+1] < 0){
                if (seen[j]){
                    cout << -1 << endl;
                    return 0;
                }
                else{
                    seen[j] = true;
                    ans.push_back(j);
                    ll x = diff[j];
                    diff[j] = diff[j+1] +1;
                    diff[j+1] = x -1;
                }
            }
            j++;
        }
        j--; //j = n-2
        while (j > 0){
            if (diff[j] > 0 && diff[j+1] < 0){
                if (seen[j]){
                    cout << -1 << endl;
                    return 0;
                }
                else{
                    seen[j] = true;
                    ans.push_back(j);
                    ll x = diff[j];
                    diff[j] = diff[j+1] +1;
                    diff[j+1] = diff[j] -1;
                }
            }
            j--;
        }
    }
    /*for (ll i = 0; i < n; i++){
        cout << diff[i] << " ";
    }
    cout << endl;*/

    for (ll i = 0; i < n-1; i++){
        cout << ans[i] +1 << endl;
    }
}
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
const int maxn=2e5+5;
int n,a[maxn],pos[maxn],vis[maxn];
vector<int> ans;
int main(){
	n=read();
	for(int i=1;i<=n;++i){
		a[i]=read();
		pos[a[i]]=i;
	}
	int cnt=0,l=1;
	for(int i=1;i<=n;++i){
		int tmp=pos[i];
		if(a[i]==i) continue;
		for(int j=l;j<pos[i]-1;++j){
			if(j+1!=a[j]){
				printf("-1\n");
				return 0;
			}
		}
		for(int j=tmp;j>l;--j){
			ans.push_back(j);
			vis[j]=1;
		}
		l=tmp;
		a[tmp]=a[tmp-1];
		pos[a[tmp]]=tmp;
		i=tmp-1;
	}
	for(int i=2;i<=n;++i){
		if(!vis[i]){
			printf("-1\n");
			return 0;
		}
	}
	for(int i=0;i<ans.size();++i) printf("%d\n",ans[i]-1);
	return 0;
}