//Bismillahir Rahmanir Raheem
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define eb emplace_back
#define vl vector<ll>
#define pa pair<ll,ll>
#define mod 1000000007
#define maxN 1000000
#define dekhao(tc,ans) cout<<"Case "<<tc<<": "<<ans<<"\n"
const double pi=acos(-1.0);
using namespace std;
void solve()
{
    ll n;
    cin>>n;
    
    vector<ll>a,b;
    for(ll i=0;i<(2*n);i++)
    {
        ll x;
        cin>>x;
        a.pb(x);
        b.pb(i+1);
    }
    if(a==b)
    {
        cout<<0<<endl;
        return;
    }
    ll ans=-1,c1=0;
    for(ll i=0;i<=(2*n);i++)
    {
        
        if(a==b)
        {
            ans=i;
            break;
        }
        if(i%2==0)
        {
            for(ll j=0;j<2*n;j+=2)
            {
                swap(b[j],b[j+1]);
            }
        }
        else
        {
            for(ll k=0;k<n;k++)
            {
                swap(b[k],b[k+n]);
            }
        }
    }
    sort(b.begin(),b.end());
    for(ll i=0;i<=(2*n);i++)
    {
        if(a==b)
        {
            if(ans==-1)
            {
                ans=i;
            }
            else
            {
                ans=min(ans,(i));
            }
            break;
        }
        if(i%2!=0)
        {
            for(ll j=0;j<2*n;j+=2)
            {
                swap(b[j],b[j+1]);
            }
        }
        else
        {
            for(ll k=0;k<n;k++)
            {
                swap(b[k],b[k+n]);
            }
        }
    }
    cout<<ans<<endl;
}
int main()
{
    #ifdef FILE_IO
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    /*int t;
    cin>>t;
    int tc=1;
    while(t--)
    {
        solve();
        tc++;
    }
    */solve();
    return 0;
}