#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  int cnt = 0, flag = 1;
  while (flag) {
    flag = 0;
    if (p[0] == 1) {
      swap(p[0], p[1]);
      cnt++;
    }
    for (int i = 1; i < n; i++) {
      if (p[i] == i + 1) {
        swap(p[i], p[i - 1]);
        cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
