#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (a % b == 0) {
    return b;
  } else {
    return gcd(b, a % b);
  }
}
int main() {
  long long int n, h = 0, w = 0;
  cin >> n;
  vector<long long int> a(200000);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i <= n; i++) {
    if (a[i] == i + 1 && i != n) {
      h++;
    } else {
      if (h > 1) {
        h--;
      }
      w += h;
      h = 0;
    }
  }
  cout << w << endl;
  return 0;
}
