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

//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//template <typename T> using orderSet =
//tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef unsigned long long llu;
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout)
#define inf 2e9
#define eps 1e-12
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define sz(x) x.size()
#define pll pair<ll, ll>
#define pii pair<int, int>
#define debug(a...) cerr<<#a<<": ",pr,a;
#define FastRead ios_base::sync_with_stdio(0);cin.tie(0);
#define cases int test; scanf("%d", &test); for(int tno=1; tno<=test; tno++)
struct print{template<typename T>print&operator,(const T& v){(v=='\n')?(cerr<<'\n'):(cerr<<v<<", ");return *this;}}pr;
ll power(ll b,ll p) {ll res=1,x=b; while(p > 0){if(p&1ll)res=res*x;x=x*x;p >>= 1;} return res;}
ll bigmod(ll b, ll p, ll m) {ll res=1, x=b%m; while(p>0){if(p&1)res=(res*x)%m;x=(x*x)%m;p>>=1;} return res;}

const ll mod = 100000007;

#define MX 2003
int arr[MX], brr[MX];

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

void op2(int n, int *a)
{
    for(int i = 0; i < n; ++i) {
        swap(a[i], a[i+n]);
    }
}

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

int main()
{
    int n;
    scanf("%d", &n);

    for(int i = 0; i < 2*n; ++i) {
        scanf("%d", &arr[i]);
        brr[i] = arr[i];
    }

    if(check(n, arr)) {
        printf("0\n");
        return 0;
    }

    int mn = inf;

    for(int i = 1; i <= 2*n; ++i) {
        if(i&1) op1(n, arr);
        else op2(n, arr);

        if(check(n, arr)) {
            mn = min(mn, i);
            break;
        }
    }

    for(int i = 1; i <= 2*n; ++i) {
        if(i&1) op2(n, brr);
        else op1(n, brr);

        if(check(n, brr)) {
            mn = min(mn, i);
            break;
        }
    }

    if(mn == inf) printf("-1\n");
    else printf("%d\n", mn);
}
