#include <bits/stdc++.h>
using namespace std;
void sw(int *a, int *b) {
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;
}
int main() {
  int n, temp, cnt = 0;
  cin >> n;
  int p[n];
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  if (p[0] == 1) {
    sw(p, p + 1);
    cnt++;
  }
  if (p[n - 1] == n) {
    sw(&p[n - 1], &p[n - 2]);
    cnt++;
  }
  for (int i = 1; i < n - 2; i++) {
    if (p[i] == i + 1) {
      sw(&p[i - 1], &p[i]);
      cnt++;
    }
  }
  cout << cnt << endl;
}
