#include <bits/stdc++.h>
using namespace std;
int N, p[100000];
bool needed[100000];
int DP();
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> p[i];
    if (p[i] == i + 1) {
      needed[i] = true;
    }
  }
  cout << DP() << endl;
  return 0;
}
void swip(int *a, int *b) {
  int buff = *a;
  *a = *b;
  *b = buff;
  return;
}
int DP() {
  int num = INT_MAX;
  bool flag = true;
  for (int i = 0; i < N; i++) {
    if (needed[i] == true) {
      flag = false;
      swip(&p[i - 1], &p[i]);
      needed[i] = false;
      if (p[i - 1] == i) {
        needed[i - 1] = true;
      } else {
        needed[i - 1] = false;
      }
      int buff = DP();
      if (num > buff + 1) {
        num = buff + 1;
      }
      needed[i] = true;
      swip(&p[i], &p[i - 1]);
      if (p[i - 1] == i) {
        needed[i - 1] = true;
      } else {
        needed[i - 1] = false;
      }
      swip(&p[i], &p[i + 1]);
      needed[i] = false;
      if (p[i + 1] == i + 2) {
        needed[i + 1] = true;
      } else {
        needed[i + 1] = false;
      }
      buff = DP();
      if (num > buff + 1) {
        num = buff + 1;
      }
      swip(&p[i + 1], &p[i]);
      needed[i] = true;
      if (p[i + 1] == i + 2) {
        needed[i + 1] = true;
      } else {
        needed[i + 1] = false;
      }
    }
  }
  if (flag == true) {
    num = 0;
  }
  return (num);
}
