#include <bits/stdc++.h>
int count;
void Finding_ara1(int* p, int n) {
  int i;
  for (i = 2; i <= n; i++) {
    if (p[i] == 1) {
      count += abs(i - 1);
      p[1] = 1;
      p[i] = 0;
      break;
    }
  }
}
void Reverse_function(int* soku, int compare) {
  int i, j;
  for (i = compare; i >= 1; i--) {
    if (i % 2 == 0 && soku[i] == 1) {
      j = i;
      while (soku[j - 1] != 0) {
        if (j - 1 == 1) break;
        j -= 2;
      }
      if (soku[j - 1] == 0) {
        count += (i - (j - 1));
        soku[j - 1] = 1;
        soku[i] = 0;
      }
    }
  }
}
int Black_function(int* soku, int n) {
  int i, j;
  count = 0;
  if (soku[1] == 0) {
    Finding_ara1(soku, n);
  }
  if (soku[1] == 1) {
    for (i = 2; i <= n; i++) {
      if (i % 2 == 0 && soku[i] == 1) Reverse_function(soku, i);
      if (i % 2 == 0 && soku[i] == 1) {
        j = i;
        while (soku[j + 1] != 0) {
          if (j + 1 == n - 1) break;
          j += 2;
        }
        if (soku[j + 1] == 0) {
          count += (j + 1 - i);
          soku[j + 1] = 1;
          soku[i] = 0;
        }
      }
    }
  }
  return count;
}
void Finding_ara2(int* p, int n) {
  int i;
  for (i = 1; i <= n; i++) {
    if (p[i] == 1) {
      count += abs(i - 2);
      p[2] = 1;
      p[i] = 0;
      break;
    }
  }
}
int White_function(int* p, int n) {
  int i, j;
  count = 0;
  if (p[2] == 0) Finding_ara2(p, n);
  if (p[2] == 1) {
    for (i = 1; i <= n; i++) {
      if (i % 2 == 1 && p[i] == 1) {
        j = i;
        while (p[j + 1] != 0) {
          if (j + 1 == n) break;
          j += 2;
        }
        if (p[j + 1] == 0) {
          count += (j + 1 - i);
          p[j + 1] = 1;
          p[i] = 0;
        }
      }
    }
  }
  for (i = n; i >= 1; i--) {
    if (i % 2 == 1 && p[i] == 1) {
      p[i] = 0;
      j = i;
      while (p[j - 1] != 0) {
        if (j - 1 == 1) break;
        j -= 2;
      }
      if (p[j - 1] == 0) {
        count += (i - (j - 1));
        p[j - 1] = 1;
      }
    }
  }
  return count;
}
int main() {
  int n, max, input, i, black, white;
  while (scanf("%d", &n) == 1) {
    int ara[n + 1], copy[n + 1];
    for (i = 1; i <= n; i++) ara[i] = 0;
    for (i = 1; i <= n / 2; i++) {
      scanf("%d", &input);
      ara[input] = 1;
    }
    for (i = 1; i <= n; i++) copy[i] = ara[i];
    black = Black_function(ara, n);
    white = White_function(copy, n);
    if (black < white)
      printf("%d\n", black);
    else
      printf("%d\n", white);
  }
  return 0;
}
