#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 5;
int a[N], n;
int ans = (1 << 30);
void DFS(int cur, int cnt) {
  if (cur > n) {
    ans = min(ans, cnt);
    return;
  }
  if (a[cur] == cur && cur != 1) {
    swap(a[cur], a[cur - 1]);
    DFS(cur + 1, cnt + 1);
    swap(a[cur], a[cur - 1]);
  }
  if (a[cur] == cur && cur != n) {
    swap(a[cur - 1], a[cur]);
    DFS(cur + 1, cnt + 1);
    swap(a[cur - 1], a[cur]);
  }
  if (a[cur] == cur && cur == 1) {
    swap(a[cur + 1], a[cur]);
    DFS(cur + 1, cnt + 1);
    swap(a[cur + 1], a[cur]);
  }
  if (a[cur] == cur && cur == n) {
    swap(a[cur], a[cur - 1]);
    DFS(cur + 1, cnt + 1);
    swap(a[cur], a[cur - 1]);
  }
  if (a[cur] != cur) DFS(cur + 1, cnt);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  DFS(1, 0);
  printf("%d\n", ans);
}
