#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long int;
int main() {
  int n;
  cin >> n;
  vector<int> num(n);
  for (long long int i = 0; i < (long long int)(n); i++) cin >> num[i];
  int cnt = 0;
  bool flag = false;
  int tmp;
  while (!flag) {
    flag = true;
    for (long long int i = 0; i < (long long int)(n); i++) {
      if (num[i] == i + 1) {
        flag = false;
        if (i == 0) {
          tmp = num[i];
          num[i] = num[i + 1];
          num[i + 1] = tmp;
        } else if (i == n - 1) {
          tmp = num[i];
          num[i] = num[i - 1];
          num[i - 1] = tmp;
        } else {
          if (num[i + 1] == i + 2) {
            tmp = num[i];
            num[i] = num[i + 1];
            num[i + 1] = tmp;
          } else {
            tmp = num[i];
            num[i] = num[i - 1];
            num[i - 1] = tmp;
          }
        }
        cnt++;
        break;
      }
    }
    if (flag) {
      cout << cnt << endl;
      return 0;
    }
  }
  return 0;
}
