#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x;
  vector<int> v;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x);
    if (x == i + 1) v.push_back(x);
  }
  int ans = 1e9;
  if (int(v.size()) % 2 == 0) {
    int c = 0;
    for (int i = 0; i < int(v.size()); i += 2) {
      c += abs(v[i] - v[i + 1]);
    }
    ans = min(ans, c);
    c = 0;
    for (int i = int(v.size()) - 1; i >= 0; i -= 2) {
      c += abs(v[i] - v[i - 1]);
    }
    ans = min(ans, c);
  } else {
    int c = 1;
    for (int i = 1; i < int(v.size()); i += 2) {
      c += abs(v[i] - v[i + 1]);
    }
    ans = min(ans, c);
    c = 1;
    for (int i = int(v.size()) - 1; i >= 1; i -= 2) {
      c += abs(v[i] - v[i - 1]);
    }
    ans = min(ans, c);
    c = 1;
    for (int i = 0; i < int(v.size()) - 1; i += 2) {
      c += abs(v[i] - v[i + 1]);
    }
    ans = min(ans, c);
    c = 1;
    for (int i = int(v.size()) - 2; i >= 0; i -= 2) {
      c += abs(v[i] - v[i - 1]);
    }
    ans = min(ans, c);
  }
  cout << ans << endl;
}
