#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  int n, ans, ans2, ans3, ans4, a;
  cin >> n;
  vector<int> v(n, 0), v2(n, 0), v3(n, 0), v4(n, 0);
  for (int i = 0; i < n / 2; i++) {
    cin >> a;
    a--;
    v[a] = 1;
    v2[a] = 1;
    v3[a] = 1;
    v4[a] = 1;
  }
  ans = 0;
  for (int i = 1; i < n; i += 2) {
    if (v[i]) {
      int j;
      for (j = 1; i + j < n and i - j >= 0; j += 2) {
        if (v[i - j] == 0) {
          v[i - j] = 1;
          ans += j;
          v[i] = 0;
          break;
        }
        if (v[i + j] == 0) {
          v[i + j] = 1;
          ans += j;
          v[i] = 0;
          break;
        }
      }
      if (v[i]) {
        for (; i - j >= 0; j += 2) {
          if (v[i - j] == 0) {
            v[i - j] = 1;
            ans += j;
            v[i] = 0;
            break;
          }
        }
      }
      if (v[i]) {
        for (; i + j < n; j += 2) {
          if (v[i + j] == 0) {
            v[i + j] = 1;
            ans += j;
            v[i] = 0;
            break;
          }
        }
      }
    }
  }
  ans2 = 0;
  for (int i = 1; i < n; i += 2) {
    if (v2[i]) {
      int j;
      for (j = 1; i + j < n and i - j >= 0; j += 2) {
        if (v2[i - j] == 0) {
          v2[i - j] = 1;
          ans2 += j;
          v2[i] = 0;
          break;
        }
        if (v2[i + j] == 0) {
          v2[i + j] = 1;
          ans2 += j;
          v2[i] = 0;
          break;
        }
      }
      if (v2[i]) {
        for (; i - j >= 0; j += 2) {
          if (v2[i - j] == 0) {
            v2[i - j] = 1;
            ans2 += j;
            v2[i] = 0;
            break;
          }
        }
      }
      if (v2[i]) {
        for (; i + j < n; j += 2) {
          if (v2[i + j] == 0) {
            v2[i + j] = 1;
            ans2 += j;
            v2[i] = 0;
            break;
          }
        }
      }
    }
  }
  cout << min(ans, ans2) << endl;
}
