#include <bits/stdc++.h>
using namespace std;
struct Queue_data {
  long long len;
  vector<long long> p;
};
int main() {
  long long ans = LLONG_MAX;
  long long N;
  cin >> N;
  vector<long long> p;
  p.resize(N);
  for (long long i = 0; i < N; i++) {
    cin >> p[i];
  }
  bool flag = true;
  for (long long i = 0; i < N; i++) {
    if (p[i] == i + 1) {
      flag = false;
      break;
    }
  }
  if (flag) {
    cout << 0 << endl;
    return 0;
  }
  queue<Queue_data> queue;
  for (long long i = 0; i < N - 1; i++) {
    vector<long long> new_p = p;
    long long tmp = new_p[i];
    new_p[i] = new_p[i + 1];
    new_p[i + 1] = tmp;
    Queue_data qd;
    qd.len = 1;
    qd.p = new_p;
    queue.push(qd);
  }
  while (!queue.empty()) {
    Queue_data qd = queue.front();
    queue.pop();
    bool flag = true;
    for (long long i = 0; i < N; i++) {
      if (qd.p[i] == i + 1) {
        flag = false;
        break;
      }
    }
    if (flag) {
      ans = qd.len;
      break;
    }
    for (long long i = 0; i < N - 1; i++) {
      vector<long long> new_p = qd.p;
      long long tmp = new_p[i];
      new_p[i] = new_p[i + 1];
      new_p[i + 1] = tmp;
      Queue_data new_qd;
      new_qd.len = qd.len + 1;
      new_qd.p = new_p;
      queue.push(new_qd);
    }
  }
  cout << ans << endl;
  return 0;
}
