#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void type1(int arr[], int n)
{
    for (int i = 0; i < n; i += 2)
        swap(arr[i], arr[i + 1]);
}
void type2(int arr[], int n)
{
    int i = 0;
    while (i < n / 2)
    {
        swap(arr[i], arr[n / 2 + i]);
        i++;
    }
}
bool check(int arr[], int n)
{
    for (int i = 0; i < n; i++)
    {
        if (arr[i] != i + 1)
            return false;
    }
    return true;
}
void solve()
{
    int n;
    cin >> n;
    n = 2 * n;
    int a1[n];
    int b1[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a1[i];
        b1[i] = a1[i];
    }
    int c1 = 0;
    int flip = 0;
    while (1)
    {
        if (a1[n - 1] == n)
        {
            if (check(a1, n))
                break;
            else
            {
                c1 = -1;
                break;
            }
        }
        else
        {
            if (flip == 0)
            {
                flip = 1;
                type1(a1, n);
            }
            else
            {
                flip = 0;
                type2(a1, n);
            }
            c1++;
        }
    }
    int c2 = 0; 
    flip = 0;
    while (1)
    {
        if (b1[n - 1] == n)
        {
            if (check(b1, n))
                break;
            else
            {
                c2 = -1;
                break;
            }
        }
        else
        {
            if (flip == 0)
            {
                flip = 1;
                type2(b1, n);
            }
            else
            {
                flip = 0;
                type1(b1, n);
            }
            c2++;
        }
    }
    if(c1 == -1){
        cout << c2 << "\n";
        return;
    }
    if(c2 == -1){
        cout << c1 << "\n";
        return;
    }
    cout << min(c1, c2) << endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //int t;
    //cin >> t;
    //while(t--){
    solve();
    //}
    return 0;
}