#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p[i];
    p[i]--;
  }
  int cnt1 = 0, cnt2 = 0;
  for (int i = 1; i < N; i++) {
    if (p[i] == i) {
      swap(p[i], p[i - 1]);
      cnt1++;
    }
  }
  for (int i = N - 2; i >= 0; i--) {
    swap(p[i], p[i + 1]);
    cnt2++;
  }
  cout << min(cnt1, cnt2) << endl;
}
