#include <bits/stdc++.h>
using namespace std;
void swap(vector<int>& p, vector<bool>& a, int i) {
  int n = p[i];
  p[i] = p[i + 1];
  p[i + 1] = n;
  a[i] = p[i] == i + 1 ? false : true;
  a[i + 1] = p[i + 1] == i + 2 ? false : true;
}
bool check(vector<bool> a, int N) {
  for (int i = 0; i < N; i++) {
    if (!a[i]) return false;
  }
  return true;
}
int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  vector<bool> a(N, true);
  for (int i = 0; i < N; i++) {
    cin >> p[i];
    if (p[i] == i + 1) a[i] = false;
  }
  int ans = 1000, cnt = 0;
  while (!check(a, N)) {
    for (int i = 0; i < N - 1; i++) {
      if (!a[i]) {
        swap(p, a, i);
        cnt++;
      }
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
}
