#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, temp, s = 0, y, i[100000], j[100000];
  cin >> a;
  for (b = 0; b < a; b++) {
    j[b] = 0;
  }
  for (b = 0; b < a; b++) {
    cin >> i[b];
    if (i[b] == b + 1) {
      j[b] = 1;
    }
  }
  for (y = 1; y < 2;) {
    for (b = 0; b < a; b++) {
      if (j[b] == 1) {
        s++;
        if (i[b + 1] != b + 1) {
          temp = i[b + 1];
          i[b + 1] = i[b];
          i[b] = temp;
        } else {
          temp = i[b - 1];
          i[b - 1] = i[b];
          i[b] = temp;
        }
      }
    }
    for (b = 0; b < a; b++) {
      if (i[b] == b + 1) {
        j[b] = 1;
      }
    }
    int x = 0;
    for (b = 0; b < a; b++) {
      if (j[b] == 1) {
        x = 1;
      }
    }
    if (x == 0) {
      goto A;
    }
  }
A:
  cout << s;
  return 0;
}
