#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int n, p1[100000], p2[100000];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &p1[i]);
    p1[i]--;
    p2[i] = p1[i];
  }
  int ans1, ans2, ans = INF;
  {
    ans1 = 0;
    for (int i = 0; i < n - 1; i++) {
      if (p1[i] == i) {
        swap(p1[i], p1[i + 1]);
        ans1++;
      }
    }
    if (p1[n - 1] != n - 1) {
      ans = min(ans, ans1);
    }
  }
  {
    ans2 = 0;
    for (int i = n - 1; i >= 1; i--) {
      if (p2[i] == i) {
        swap(p2[i], p2[i - 1]);
        ans2++;
      }
    }
    if (p2[0] != 0) {
      ans = min(ans, ans2);
    }
  }
  printf("%d\n", ans);
  return 0;
}
