#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  vector<bool> a(n);
  int count = 0;
  int c = 1;
  for (int i = 0; i < n; i++) cin >> p[i];
  for (int i = 0; i < n; i++) a[i] = (i + 1 == p[i]);
  while (c == 1) {
    c = 0;
    for (int i = 0; i < n - 1; i++) {
      if (a[i]) {
        count++;
        swap(p[i], p[i + 1]);
        a[i] = (i + 1 == p[i]);
        a[i + 1] = (i + 2 == p[i + 1]);
        if (a[i] == 1) c = 1;
      }
    }
  }
  cout << count << endl;
}
