#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, r1 = 0, r2 = 0;
  cin >> n;
  int a[n + 10], b[n + 10];
  map<int, int> m;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  for (i = 1; i <= n; i++) {
    if (b[i] == i) {
      r1++;
      swap(b[i], b[i + 1]);
    }
  }
  for (i = 1; i <= n; i++) {
    if (a[i] == i) {
      r2++;
      if (i == 1)
        swap(a[i], a[n]);
      else
        swap(a[i], a[i + 1]);
    }
  }
  cout << min(r1, r2);
  return 0;
}
