#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  int ans = 0;
  if (v[0] == 1) {
    swap(v[0], v[1]);
    ans++;
  }
  if (v[n - 1] == n) {
    swap(v[n - 1], v[n - 2]);
    ans++;
  }
  for (int i = 1; i < n - 1; i++) {
    int now = i + 1;
    if (v[i] == now) {
      if (v[i - 1] != now)
        swap(v[i - 1], v[i]);
      else
        swap(v[i], v[i + 1]);
      ans++;
    }
  }
  cout << ans << endl;
}
