// https://codeforces.com/contest/1510/problem/K
#include <string>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <set>
#include <queue>
using namespace std;

const int maxn = 1001;
int n, a[2*maxn], ans=-1;

void swap(int &x, int &y) {	x^=y; y^=x; x^=y; }
int min(int x, int y) { return x<y?x:y; }

void op(int type)
{
	if (type==1)
		for (int i=0; i<2*n; i+=2)
			swap(a[i], a[i+1]);
	else
		for (int i=0; i<n; i++)
			swap(a[i], a[i+n]);
}

bool check()
{
	for (int i=0; i<2*n; i++)
		if  (a[i]!=i+1)
			return false;
	return true;
}

int main()
{
	scanf("%d", &n);
	for (int i=0; i<2*n; i++)
		scanf("%d", &a[i]);
	int limit = 0;
	if (n%2==0) limit=4;
	else limit=2*n;
	if (check()) ans = 0;
	else
	{
		for (int k=1; k<limit; k++)// 最多做limit个操作，即可知道是否可能排序
		{
			if (k%2==0) op(1);
			else op(2);
			if (check())
			{
				ans = min(k, limit-k);
				break;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}