#include <bits/stdc++.h>
unsigned count = 0;
void swap(std::vector<int>& P, unsigned ii) {
  int temp = P[ii + 1] + 1;
  P[ii + 1] = P[ii] - 1;
  P[ii] = temp;
  count++;
}
int main() {
  int N;
  std::cin >> N;
  std::vector<int> P(N);
  for (int ii = 0; ii < N; ++ii) {
    int p;
    std::cin >> p;
    P[ii] = p - ii - 1;
  }
  if (P[0] == 0) swap(P, 0);
  if (P[N - 1] == 0) swap(P, N - 2);
  bool is_all_good = false;
  while (!is_all_good) {
    is_all_good = true;
    for (int ii = 1; ii < N - 1; ++ii) {
      if (P[ii] != 0) continue;
      is_all_good = false;
      if (P[ii - 1] != 1)
        swap(P, ii - 1);
      else
        swap(P, ii);
    }
  }
  std::cout << count << std::endl;
  return 0;
}
