#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> p(n), q(n);
  for (int i = (0); i < (int)(n); i++) {
    int a;
    cin >> a;
    p[i] = a - 1;
    q[i] = a - 1;
  }
  int count1 = 0;
  int count2 = 0;
  for (int i = (0); i < (int)(n - 1); i++) {
    if (p[i] == i) {
      int tmp = p[i];
      p[i] = p[i + 1];
      p[i + 1] = tmp;
      ++count1;
    }
  }
  for (int i = n - 1; i > 0; i--) {
    if (q[i] == i) {
      int tmp = q[i];
      q[i] = q[i - 1];
      q[i - 1] = tmp;
      ++count2;
    }
  }
  cout << min(count1, count2);
}
