#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int max(int a, int b) {
  if (a > b)
    return a;
  else
    return b;
}
int min(int a, int b) {
  if (a < b)
    return a;
  else
    return b;
}
int avd_i(int a, int b) {
  if (a > b)
    return a - b;
  else
    return b - a;
}
double avd_d(double a, double b) {
  double re;
  if (a > b)
    re = a - b;
  else
    re = b - a;
  return re;
}
long long int calc(long long int a, long long int b, long long int p) {
  if (b == 0) {
    return 1;
  } else if (b % 2 == 0) {
    long long int d = calc(a, b / 2, p);
    return ((d % p) * (d % p)) % p;
  } else {
    return ((a % p) * calc(a, b - 1, p) % p) % p;
  }
}
long long int CMOD(long long int n, long long int r, long long int p) {
  long long int a = 1, b = 1, c = 1, re;
  for (int i = 1; i <= n; i++) {
    a *= i;
    a = a % p;
  }
  for (int i = 1; i <= r; i++) {
    b *= i;
    b = b % p;
  }
  for (int i = 1; i <= n - r; i++) {
    c *= i;
    c = c % p;
  }
  b = calc(b, p - 2, p);
  c = calc(c, p - 2, p);
  re = ((a % p) * (b % p)) % p;
  re = ((re % p) * c % p) % p;
  return re;
}
int main() {
  long long int N, p[100005], count = 0, ans = 0;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> p[i];
    if (count != 0) count++;
    if (p[i] == i) {
      if (count == 0) {
        count++;
      } else {
        ans += count - 1;
        count = 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
