#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll paletta_sort(int N, int V[])
{
	if (N%2==0)
	{
	vector<int> b(N/2);
	vector<int> a(N/2);
	for (int i=0; i<N/2; i++)
	{
		b[i]=V[i*2];
	}
	for (int i=0; i<N/2; i++)
	{
		a[i]=V[(i*2)+1];
	}
	sort(b.begin(), b.end());
	sort(a.begin(), a.end());
	int c=0;
	for (int i=0; i<N/2; i++)
	{
		if (b[i]<a[i])
		{
			c++;
		}
	}
	if (c==(N/2))
	{
		if (N==6)
		{
			return 3;
		}
		else
		{
			return 1;
		}
	}
	else 
	{
		return -1;
	}

	}
	else
	{
	vector<int> b(N/2);
	vector<int> a((N/2)+1);
	for (int i=0; i<N/2; i++)
	{
		b[i]=V[i*2];
	}
	for (int i=0; i<=(N/2); i++)
	{
		a[i]=V[(i*2)+1];
	}
	sort(b.begin(), b.end());
	sort(a.begin(), a.end());
	int d=0;
	for (int i=0; i<N/2; i++)
	{
		if (b[i]<a[i])
		{
			d++;
		}
	}
	if (b[(N/2)-1]<a[N/2])
	{
		d++;
	}
	if (d==(N/2)+1)
	{
		if (N==6)
		{
			return 3;
		}
		else
		{
			return 1;
		}
	}
	else 
	{
		return -1;
	}		
	}
	
}




