#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < (int)n; i++) {
    cin >> p[i];
  }
  int tmp = 0;
  int ans = 1 << 30;
  bool find = false;
  int mem = 0;
  for (int i = 0; i < (int)n; i++) {
    if (p[i] == i + 1) {
      if (find) {
        tmp += i - mem;
      } else {
        mem = i;
      }
      find = !find;
    }
  }
  if (find) tmp++;
  ans = min(ans, tmp);
  tmp = 0;
  find = false;
  for (int i = n - 1; i >= 0; i--) {
    if (p[i] == i + 1) {
      if (find) {
        tmp += abs(i - mem);
      } else {
        mem = i;
      }
      find = !find;
    }
  }
  if (find) tmp++;
  ans = min(ans, tmp);
  cout << ans << endl;
  return 0;
}
