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