#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  long long cnt = 0;
  bool hantei = false;
  int start = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == i + 1 && hantei == false) {
      start = i;
      hantei = true;
    } else if (a[i] == i + 1 && hantei == true) {
      int sa = i - start;
      cnt += sa;
      hantei = false;
    }
  }
  cout << cnt << endl;
  return 0;
}
