#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  bool fc = 1;
  int p[114514];
  int q[114514];
  int r[114514];
  int ans1 = 0;
  int ans2 = 0;
  int ans3 = 0;
  cin >> N;
  for (int i = 0; i < (N); i++) {
    cin >> p[i];
    q[i] = p[i];
    r[i] = p[i];
    if (p[i] == i + 1) {
      fc = 0;
    }
  }
  if (fc == 1) {
    cout << 0 << endl;
  } else {
    for (int i = 0; i < (N - 1); i++) {
      if (p[i] == i + 1) {
        swap(p[i], p[i + 1]);
        ans1++;
      }
    }
    if (p[N - 1] == N) {
      ans1 = 1145141919;
    }
    for (int i = N - 1; i > 0; i--) {
      if (q[i] == i + 1) {
        swap(q[i - 1], q[i]);
        ans2++;
      }
      if (q[0] == 1) {
        ans2 = 1145141919;
      }
    }
    for (int i = 0; i <= (N + 1) / 2; i++) {
      if (r[i] == i + 1) {
        swap(r[i], r[i + 1]);
        ans3++;
      }
      if (r[N - 1 - i] == N - i) {
        swap(r[i - 1], r[i]);
        ans3++;
      }
    }
    if ((r[N / 2] == N / 2 + 1) || (r[N / 2 - 1] == N / 2) ||
        (r[N / 2 + 1] == N / 2 + 2)) {
      ans3 = 1145141919;
    }
    if (ans1 != 0 || ans2 != 0 || ans3 != 0) {
      cout << min({ans1, ans2, ans3}) << endl;
    } else {
      cout << (N + 1) / 2 << endl;
    }
  }
  return 0;
}
