#include <bits/stdc++.h>
using namespace std;
const int N = 1e2 + 5;
struct node {
  vector<int> a;
  int d;
};
bool check(node v, int n) {
  for (int i = 0; i < n; i++)
    if (v.a[i] == i + 1) return false;
  return true;
}
queue<node> qlist;
int solve(int n, node start) {
  qlist.push(start);
  while (!qlist.empty()) {
    node v = qlist.front();
    qlist.pop();
    if (check(v, n)) return v.d;
    for (int i = 0; i < n; i++) {
      if (v.a[i] == i + 1) {
        node u, u1;
        for (int j = 0; j < n; j++) {
          u.a.push_back(v.a[j]);
          u1.a.push_back(v.a[j]);
        }
        if (i == 0) {
          swap(u.a[i], u.a[i + 1]);
          u.d = v.d + 1;
          qlist.push(u);
          break;
        } else if (i == n - 1) {
          swap(u.a[i], u.a[i - 1]);
          u.d = v.d + 1;
          qlist.push(u);
          break;
        } else {
          swap(u.a[i + 1], u.a[i]);
          swap(u1.a[i - 1], u1.a[i]);
          u.d = u1.d = v.d + 1;
          qlist.push(u);
          qlist.push(u1);
          break;
        }
      }
    }
  }
}
int main() {
  node start;
  int n;
  cin >> n;
  int tm;
  for (int i = 1; i <= n; i++) {
    cin >> tm;
    start.a.push_back(tm);
  }
  start.d = 0;
  cout << solve(n, start);
  return 0;
}
