#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll p_front[1000000] = {0};
ll p_back[1000000] = {0};
int main() {
  ll N;
  cin >> N;
  for (ll n = 1; n < N + 1; n++) {
    int p;
    cin >> p;
    p_front[n] = p;
    ;
    p_back[n] = p;
  }
  ll cnt_front = 0;
  if (p_front[1] == 1) {
    swap(p_front[1], p_front[2]);
    cnt_front++;
  }
  for (ll n = 2; n < N; n++) {
    if (p_front[n] == n) {
      ll prevlen = n - p_front[n - 1];
      ll nextlen = p_front[n + 1] - n;
      if (prevlen >= nextlen) {
        swap(p_front[n], p_front[n - 1]);
      } else {
        swap(p_front[n], p_front[n + 1]);
      }
      cnt_front++;
    }
  }
  if (p_front[N] == N) {
    swap(p_front[N], p_front[N - 1]);
    cnt_front++;
  }
  ll cnt_back = 0;
  if (p_back[N] == N) {
    swap(p_back[N], p_back[N - 1]);
    cnt_back++;
  }
  for (ll n = N - 1; n > 1; n--) {
    if (p_back[n] == n) {
      ll prevlen = n - p_back[n - 1];
      ll nextlen = p_back[n + 1] - n;
      if (prevlen >= nextlen) {
        swap(p_back[n], p_back[n - 1]);
      } else {
        swap(p_back[n], p_back[n + 1]);
      }
      cnt_back++;
    }
  }
  if (p_back[1] == 1) {
    swap(p_back[1], p_back[2]);
    cnt_back++;
  }
  if (cnt_front > cnt_back) {
    cout << cnt_back << endl;
  } else {
    cout << cnt_front << endl;
  }
  return 0;
}
