#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int N; cin >> N; 
	int A[200010]; 
	int X[200010]; 
	for(int i = 1; i <= N; i++){
		cin >> A[i]; 
		X[A[i]] = i; 
	}
	vector<int> op; 
	for(int i = 1; i <= N; i++){
		if(A[i] == i) continue; 
		int a = X[i]; 
		for(int j = a-1; j >= i; j--){
			X[A[j]] = j+1; X[A[j+1]] = j; 
			swap(A[j], A[j+1]); 
			op.push_back(j); 
		}
		for(int j = i; j < a; j++){
			if(A[j] != j){
				cout << -1 << "\n"; return 0; 
			}
		}
	}
	if((int) op.size() != N-1) cout << -1 << endl; 
	else{
		for(auto i : op) cout << i << "\n"; 
	}
}
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define lli long long int
#define double long double
#define all(x) x.begin(),x.end()
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define siz(x) x.size()
#define prs(x,y) x.find(y)!=x.end()
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define forn(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res;}
inline int level(int n){int ans=0;while(n%2==0){n/=2;ans++;}return ans;}
#define gog(T,x) cout<<"Case #"<<T<<": "<<x<<"\n";
#define pii pair<int,int>
vector<pii> fw,bc;
vector<int> xs;
vector<int> vis;
vector<map<int,int> > mp;
queue<int> qu;
vector<int> ans;
void solve()
{
	while(!qu.empty())
	{
		int y=qu.front();
		ans.push_back(y+1);
		qu.pop();
		xs[fw[y].first]++;
		xs[bc[y].first]++;
		int ff=fw[y].first;
		int bb=bc[y].first;
		int ffs=mp[ff][xs[ff]];
		int bbs=mp[bb][xs[bb]];
		if(!vis[ffs] && xs[fw[ffs].first]==fw[ffs].second && xs[bc[ffs].first]==bc[ffs].second)
		{
			vis[ffs]=true;
			qu.push(ffs);
		}
		if(!vis[bbs] && xs[fw[bbs].first]==fw[bbs].second && xs[bc[bbs].first]==bc[bbs].second)
		{
			vis[bbs]=true;
			qu.push(bbs);
		}

	}
}
int main()
{
	fast_io //REMOVE FOR interactive problems
	lli n;
	cin>>n;
	fw=vector<pii>(n+1,{-1,-1});
	bc=vector<pii>(n+1,{-1,-1});
	xs=vector<int>(n+1,0);
	vis=vector<int>(n+1,0);
	mp=vector<map<int,int> >(n+1);
	forn(i,n)
	{
		int x;
		cin>>x;
		x--;
		int cnt=0;
		if(x>i)
		{
			for(int j=i;j<x;j++)
			{
				if(fw[j]!=make_pair(-1,-1))
				{
					cout<<-1;
					return 0;
				}
				fw[j]={x,cnt};
				mp[x][cnt]=j;
				cnt++;
			}
		}
		else if(x==i)
		{
			cout<<-1;
			return 0;
		}
		else
		{
			for(int j=i-1;j>=x;j--)
			{
				if(bc[j]!=make_pair(-1,-1))
				{
					cout<<-1;
					return 0;
				}
				bc[j]={x,cnt};
				mp[x][cnt]=j;
				cnt++;
			}
		}

	}
	forn(i,n-1)
	{
		if(bc[i]==make_pair(-1,-1) || fw[i]==make_pair(-1,-1))
		{
			cout<<-1;
			return 0;
		}
		else if(bc[i].second==0 && fw[i].second==0)
		{
			vis[i]=true;
			qu.push(i);
		}
	}
	solve();
	if((lli)ans.size()!=n-1)
	{cout<<-1;return 0;}
	for(auto x: ans)
		cout<<x<<"\n";
}

