#include <bits/stdc++.h>
using namespace std;
int n, ans = 0;
vector<int> v;
int main() {
  cin >> n;
  int a[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] == i) v.push_back(i);
  }
  if (v.size() == 0)
    cout << 0 << endl;
  else if (v.size() == 1)
    cout << 1 << endl;
  else {
    for (int i = 0; i < v.size(); i++) {
      if (i == 0) {
        ans += v[i + 1] - v[i];
        if (i + 1 == v.size() - 1)
          break;
        else
          i += 1;
      } else if (i == v.size() - 1) {
        ans += v[i] - v[i - 1];
        break;
      } else {
        if (v[i + 1] - v[i] <= v[i] - v[i - 1]) {
          ans += v[i + 1] - v[i];
          if (i + 1 == v.size() - 1)
            break;
          else
            i += 1;
        } else {
          ans += v[i] - v[i - 1];
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
