#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long int
#define ll long long int
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define mem memset
#define ff first
#define ss second
#define loop0(i,n) for(i=0;i<n;i++)
#define loop1(i,n) for(i=1;i<=n;i++)
ll dist(pair<ll,ll> p1,pair<ll,ll> p2)
{
	return max(abs(p1.ff-p2.ff),abs(p1.ss-p2.ss));
}
int main()
{
	ll n,i,j,x,y,k,l,a,b;
	cin>>n;
	pair<pair<ll,ll>,ll> p[n],q[n];
	loop0(i,n)
	{
		cin>>x>>y;
		p[i]={{x,y},i};
		q[i]={{y,x},i};
	}
	sort(p,p+n);
	sort(q,q+n);
	priority_queue<ll> pq;
	map<pair<ll,ll>,ll> mp;
	ll ans;
	a=p[0].ss;b=p[n-1].ss;
	x=min(a,b);y=max(a,b);
	if(!mp[{x,y}])
	{
		pq.push(dist(p[0].ff,p[n-1].ff));
		mp[{x,y}]=1;
	}
	a=p[0].ss;b=p[n-2].ss;
	x=min(a,b);y=max(a,b);
	if(!mp[{x,y}])
	{
		pq.push(dist(p[0].ff,p[n-2].ff));
		mp[{x,y}]=1;
	}
	a=p[1].ss;b=p[n-1].ss;
	x=min(a,b);y=max(a,b);
	if(!mp[{x,y}])
	{
		pq.push(dist(p[1].ff,p[n-1].ff));
		mp[{x,y}]=1;
	}
	a=q[0].ss;b=q[n-1].ss;
	x=min(a,b);y=max(a,b);
	if(!mp[{x,y}])
	{
		pq.push(dist(q[0].ff,q[n-1].ff));
		mp[{x,y}]=1;
	}
	a=q[0].ss;b=q[n-2].ss;
	x=min(a,b);y=max(a,b);
	if(!mp[{x,y}])
	{
		pq.push(dist(q[0].ff,q[n-2].ff));
		mp[{x,y}]=1;
	}
	a=q[1].ss;b=q[n-1].ss;
	x=min(a,b);y=max(a,b);
	if(!mp[{x,y}])
	{
		pq.push(dist(q[1].ff,q[n-1].ff));
		mp[{x,y}]=1;
	}
	pq.pop();
	ans=pq.top();
	cout<<ans<<'\n';
	return 0;
}
#include <bits/stdc++.h>
#define rei register int
using namespace std;

const int N=2e5+100;
int a[N],num[N],ans[N];
int n,p;
bool used[N];

inline void change(int j){
	used[j]=true;
	ans[++p]=j;
	num[a[j]]=j+1;
	num[a[j+1]]=j;
	swap(a[j],a[j+1]);
}

int main(){
	cin>>n;
	for(rei i=1;i<=n;++i){
		cin>>a[i];
		num[a[i]]=i;
	}
	memset(used,false,sizeof used);
	for(rei i=1;i<=n;++i) 
	    for(rei j=num[i]-1;j>=i;--j){
	    	if(used[j]){
	    		puts("-1");
	    		return 0;
	    	}
	    	change(j);
	    }
	if(p!=n-1){
		puts("-1");
		return 0;
	}
	for(rei i=1;i<=n-1;++i)
	    cout<<ans[i]<<endl;    
	return 0;    
}
