#include <bits/stdc++.h>
using namespace std;
int stp = 0;
int sooto(int j[], int s[], int N) {
  int i, n;
  n = N;
  for (i = 0; i < n; i++) {
    if (s[i] == 0) {
      if (i == 0) {
        swap(j[i], j[i + 1]);
        s[i]--;
        s[i + 1]++;
        stp++;
        continue;
      } else if (i != n - 1) {
        if (s[i - 1] != 1) {
          swap(j[i], j[i - 1]);
          s[i]++;
          s[i - 1]--;
          stp++;
          continue;
        } else {
          swap(j[i], j[i + 1]);
          s[i]--;
          s[i + 1]++;
          stp++;
          continue;
        }
      } else {
        swap(j[i], j[i - 1]);
        s[i]++;
        s[i - 1]--;
        stp++;
        continue;
      }
    }
  }
  int coun = 0;
  for (i = 0; i < n; i++) {
    if (s[i] == 0) coun++;
  }
  return coun;
}
int main() {
  int n, jun[114514], soe[114514];
  scanf("%d", &n);
  int i;
  for (i = 0; i < n; i++) {
    scanf("%d", &jun[i]);
    soe[i] = jun[i] - (i + 1);
  }
  while (sooto(jun, soe, n) != 0)
    ;
  printf("%d\n", stp);
}
