#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;
int main() {
  int n, cnt = 0;
  bool flag = true;
  cin >> n;
  vector<int> arr(n), ar(n);
  iota(ar.begin(), ar.end(), 1);
  for (int i = 0; i < (int)(n); i++) cin >> arr[i];
  while (1) {
    flag = true;
    for (int i = 0; i < (int)(n - 1); i++) {
      if (ar[i] == arr[i]) {
        flag = false;
        swap(arr[i], arr[i + 1]);
        cnt++;
      }
    }
    if (flag) break;
  }
  cout << cnt << endl;
  return 0;
}
