#include <bits/stdc++.h>
using namespace std;
void CINT() {}
template <class Head, class... Tail>
void CINT(Head&& head, Tail&&... tail) {
  cin >> head;
  CINT(move(tail)...);
}
const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;
int N;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  vector<int> p(N);
  for (int i = (int)0; i < (int)N; ++i) {
    int tmp;
    CINT(tmp);
    tmp--;
    p[i] = i - tmp;
  }
  int last = -1;
  int ans = INF;
  int tmp = 0;
  for (int i = (int)0; i < (int)N; ++i) {
    if (p[i] == 0) {
      if (last == -1)
        last = i;
      else {
        tmp += min(i - last, 2);
        last = -1;
      }
    }
  }
  if (last != -1) {
    tmp++;
  }
  ans = min(ans, tmp);
  last = -1;
  tmp = 0;
  for (int i = (int)N - 1; i >= (int)0; --i) {
    if (p[i] == 0) {
      if (last == -1)
        last = i;
      else {
        tmp += min(last - i, 2);
        last = -1;
      }
    }
  }
  if (last != -1) {
    tmp++;
  }
  ans = min(ans, tmp);
  cout << ans << endl;
  return 0;
}
