#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
  int n;
  cin >> n;
  int cnt = 0;
  map<int, int> mp;
  int arr_cnt = 0;
  for (int i = int(0); i < int(n); ++i) {
    int t;
    cin >> t;
    if (t == i + 1) {
      ++arr_cnt;
    } else {
      if (arr_cnt == 0) continue;
      if (mp.find(arr_cnt) == mp.end()) {
        mp[arr_cnt] = 1;
      } else {
        mp[arr_cnt] = mp[arr_cnt] + 1;
      }
      arr_cnt = 0;
    }
  }
  if (arr_cnt > 0) {
    if (mp.find(arr_cnt) == mp.end()) {
      mp[arr_cnt] = 1;
    } else {
      mp[arr_cnt] = mp[arr_cnt] + 1;
    }
  }
  int out = 0;
  for (auto&& ele : mp) {
    if (ele.first == 1) {
      out += ele.second;
    } else {
      out += (ele.first - 1) * ele.second;
    }
  }
  cout << out << endl;
  return 0;
}
