#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  bool fc = 1;
  int p[114514];
  int q[114514];
  int ans1 = 0;
  int ans2 = 0;
  cin >> N;
  for (int i = 0; i < (N); i++) {
    cin >> p[i];
    q[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;
    }
    cout << min(ans1, ans2) << endl;
  }
  return 0;
}
