#include <bits/stdc++.h>
const signed long long int MAX_SLLI = 0x7FFFFFFFFFFFFFFF;
const signed long long int MIN_SLLI = 0x8000000000000000;
const unsigned long long int MAX_ULLI = 0xFFFFFFFFFFFFFFFF;
const unsigned long long int MIN_ULLI = 0x0000000000000000;
int main() {
  long N;
  std::cin >> N;
  std::vector<long> p(N);
  for (long n = 0; n < N; ++n) {
    std::cin >> p[n];
  }
  std::vector<long> q(N);
  for (long n = 0; n < N; ++n) {
    q[n] = p[n] - (n + 1);
  }
  unsigned c = 0;
  for (long n = 0; n < N - 1; ++n) {
    if (q[n] == 0) {
      --q[n + 0];
      ++q[n + 1];
      ++c;
    }
  }
  std::cout << c << std::endl;
  return 0;
}
