#include <bits/stdc++.h>
#define ll long long
#define loop(i, a, b) for(ll i=a;i<b;++i)
#define pool(i, a, b) for(ll i=a-1;i>=b;--i)
#define fore(i, a) for(auto&& i:a)
#define fi first
#define se second
#define ps(a) push_back(a)
#define pb(a) pop_back(a)
#define eb(...) emplace_back(__VA_ARGS__)
#define sc scanf
#define vc vector
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define llmax LLONG_MAX/2
#define llmin -LLONG_MAX/2
using namespace std;
#define mn 500100
#define par pair<ll, ll>
#define ld long double
#define mod 1000000007

int main() {
    ll n;cin >> n;
    vc<ll> a(2 * n), p(2 * n);
    loop(i, 0, 2 * n) cin >> a[i];
    
    
    ll ans=llmax;
    
    p=a;
    
    {
    ll br=1;
    loop(i, 0, 2 * n) if(p[i]!=i+1) br=0;
    if(br) {ans=min(ans, (ll)0);}
    }

    for(ll t=0;t<2500;t+=2){
        
        for(ll i=0; i<2 * n;i+=2) swap(p[i], p[i+1]);
        ll br=1;
        loop(i, 0, 2 * n) if(p[i]!=i+1) br=0;
        if(br) {ans=min(ans, t+1); break;}
        
        loop(i, 0, n) swap(p[i], p[i+n]);
        br=1;
        loop(i, 0, 2 * n) if(p[i]!=i+1) br=0;
        if(br) {ans=min(ans, t+2); break;}
        
    }

    p=a;
    for(ll t=0;t<2500;t+=2){
        loop(i, 0, n) swap(p[i], p[i+n]);
        ll br=1;
        loop(i, 0, 2 * n) if(p[i]!=i+1) br=0;
        if(br) {ans=min(ans, t+1); break;}
        
        for(ll i=0; i<2 * n;i+=2) swap(p[i], p[i+1]);
        br=1;
        loop(i, 0, 2 * n) if(p[i]!=i+1) br=0;
        if(br) {ans=min(ans, t+2); break;}
    }

    if(ans==llmax) cout << -1 <<endl;
    else cout << ans << endl;
}