#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  int n;
  cin >> n;
  vector<int> list(n);
  for (int i = 0; i < n; i++) {
    cin >> list[i];
  }
  queue<pair<vector<int>, int> > q;
  q.push(make_pair(list, 0));
  while (true) {
    pair<vector<int>, int> curr = q.front();
    q.pop();
    bool solved = true;
    int index = 0;
    for (int i = 0; i < n; i++) {
      if (curr.first[i] == i + 1) {
        solved = false;
        index = i;
        break;
      }
    }
    if (solved) {
      cout << curr.second << endl;
      break;
    } else {
      if (index != 0) {
        vector<int> list_move_l = curr.first;
        int temp = list_move_l[index - 1];
        list_move_l[index - 1] = list_move_l[index];
        list_move_l[index] = temp;
        q.push(make_pair(list_move_l, curr.second + 1));
      }
      if (index != n - 1) {
        vector<int> list_move_r = curr.first;
        int temp = list_move_r[index + 1];
        list_move_r[index + 1] = list_move_r[index];
        list_move_r[index] = temp;
        q.push(make_pair(list_move_r, curr.second + 1));
      }
    }
  }
  return 0;
}
