#include <bits/stdc++.h>
using namespace std;
int n, a[20], b[20], e, o, res, cnd;
vector<pair<int, int> > even, odd, vc;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  o = n / 2;
  e = n - o;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  res = 1e9;
  for (int msk = 0; msk < (1 << n); msk++) {
    even.clear();
    odd.clear();
    vc.clear();
    for (int i = 0; i < n; i++) {
      if (msk & (1 << i)) {
        if (i % 2 == 0)
          odd.push_back(make_pair(b[i], i));
        else
          even.push_back(make_pair(b[i], i));
      } else {
        if (i % 2 == 0)
          even.push_back(make_pair(a[i], i));
        else
          odd.push_back(make_pair(a[i], i));
      }
    }
    sort(even.begin(), even.end());
    sort(odd.begin(), odd.end());
    if ((even.size() != e) || (odd.size() != o)) continue;
    for (int i = 0; i < o; i++) {
      vc.push_back(even[i]);
      vc.push_back(odd[i]);
    }
    if (e != o) vc.push_back(even[e - 1]);
    cnd = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        cnd += ((vc[j].second) < (vc[i].second));
      }
    }
    res = min(res, cnd);
  }
  cout << res << endl;
  return 0;
}
