#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 7;
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main() {
  long long N;
  cin >> N;
  long long a[N];
  for (int i = 0; i < (int)(N); i++) cin >> a[i];
  long long ans = 0;
  if (a[0] == 1) {
    swap(a[0], a[1]);
    ans++;
  }
  if (a[N - 1] == N) {
    swap(a[N - 2], a[N - 1]);
    ans++;
  }
  for (int i = 1; i < N - 1; i++) {
    if (a[i] == i + 1) {
      if (a[i - 1] > a[i + 1]) {
        swap(a[i], a[i + 1]);
        ans++;
      } else {
        swap(a[i], a[i - 1]);
        ans++;
      }
    }
  }
  cout << ans << endl;
}
