#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i++)
#define pb push_back
#define st first
#define nd second
#define pq priority_queue
#define all(x) begin(x), end(x)
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
 
const int mxn = 2e3;
const ll inf = 1e18;
const int i_inf = 1e9;
const ll mod = 1000003;
mt19937 _rand(time(NULL));
clock_t z;
//while((clock()-z)/CLOCKS_PER_SEC > 0.9)

int n;
int a[mxn];

int c[mxn];
void op(int t){
	if(t == 0){
		for(int i = 0; i < n; i += 2){
			swap(c[i], c[i+1]);
		}
	}
	else{
		for(int i = 0; i < n/2; i ++){
			swap(c[i], c[i+n/2]);
		}
	}
}


bool sorted(){
	fr(i, 0, n) if(c[i] != i+1) return false;
	return true;
}


void solve(){
	cin >> n;
	n <<= 1;
	fr(i, 0, n){
		cin >> a[i];
	}
	
	fr(i, 0, n) c[i] = a[i];
	int t;
	for(t = 0; t < 4 * n && c[0] != 1; t++){
		op(t&1);
	}
	int ans = i_inf;
	if(sorted()) ans = t;
	
	
	fr(i, 0, n) c[i] = a[i];
	for(t = 1; t < 4*n && c[0] != 1; t ++){
		op(t&1);
	}
	if(sorted()) ans = min(ans, t-1);
	
	if(ans == i_inf) cout<<-1<<endl;
	else  cout<<ans<<endl;
	
	
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	
	while(t--){
		solve();
	}
	return 0;
}



