#include <bits/stdc++.h>
using namespace std;

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define INF 2000000000000000000LL
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug//in.txt","r",stdin)
#define write freopen("debug//out.txt","w",stdout)
#define DBG(a) cerr<<#a<<" ->->->-> "<<a<<"\n"
#define fi first
#define se second
#define PI (acos(-1))
#define fastread ios::sync_with_stdio(false);cin.tie(NULL)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mod (1000000007)
#define asz 300005

template<class T,class V> ostream& operator<<(ostream &s,pair<T,V> a)
{
    s<<a.fi<<' '<<a.se;
    return s;
}

const int N = 1e6+3, K = 26;

int main()
{
    fastread;
#ifdef FILE_IO2
    read;
    write;
#endif
    int T=1;
//    cin>>T;
    for(int qq=1; qq<=T; qq++)
    {
		int n;
		cin>>n;
		vi v(2*n);
		for(auto &x:v)cin>>x;
		
		vi temp(2*n);
		
		for(int i=1;i<=2*n;i++)temp[i-1] = i;
		int ans = -1;
		for(int i=0;i<=2*n;i++){
			if(temp == v){
				ans = i;
				break;
			}
			if(i%2){
				for(int j=0;j<2*n;j+=2)swap(temp[j],temp[j+1]);
			}
			else{
				for(int j=0;j<n;j++)swap(temp[j],temp[j+n]);
			}
		}
		
		for(int i=1;i<=2*n;i++)temp[i-1] = i;
		
		for(int i=0;i<=2*n;i++){
			if(temp == v){
				if(ans==-1)ans = i;
				else ans = min(ans,i);
				break;
			}
			if(i%2==0){
				for(int j=0;j<2*n;j+=2)swap(temp[j],temp[j+1]);
			}
			else{
				for(int j=0;j<n;j++)swap(temp[j],temp[j+n]);
			}
		}
		
		cout<<ans<<endl;
    }
}
