#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3c3c3c3c;
const long long infl = 0x3c3c3c3c3c3c3c3c;
const int MAX_N = 109;
int n;
int p[MAX_N];
char s[MAX_N];
bool used[MAX_N];
char type[] = {'B', 'W'};
int getAnswer(int t) {
  int res = 0;
  memset(used, false, sizeof(used));
  for (int i = 0; i < n / 2; i++) {
    if (s[p[i]] == type[t]) used[p[i]] = true;
  }
  for (int i = 0; i < n / 2; i++) {
    if (s[p[i]] == type[t]) continue;
    for (int j = 1; j <= n; j++) {
      if (p[i] - j >= 1 && !used[p[i] - j] && s[p[i] - j] == type[t]) {
        used[p[i] - j] = true;
        res += j;
        break;
      } else if (p[i] + j <= n && !used[p[i] + j] && s[p[i] + j] == type[t]) {
        used[p[i] + j] = true;
        res += j;
        break;
      }
    }
  }
  return res;
}
int main() {
  cin.tie(NULL);
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    if (i % 2)
      s[i] = 'B';
    else
      s[i] = 'W';
  }
  for (int i = 0; i < n / 2; i++) cin >> p[i];
  printf("%d", min(getAnswer(0), getAnswer(1)));
  return 0;
}
