#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, ans = 0, left, right;
  int p[100000] = {0};
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }
  if (p[0] == 1) {
    ans++;
    left = p[0];
    right = p[1];
    p[0] = right;
    p[1] = left;
  }
  if (N % 2 == 1 && p[N - 1] == N) {
    ans++;
    left = p[N - 2];
    right = p[N - 1];
    p[N - 2] = right;
    p[N - 1] = left;
  }
  for (int i = 0; 2 * i < N - 1; i++) {
    if (p[2 * i] == 2 * i + 1 || p[2 * i + 1] == 2 * i + 2) {
      ans++;
      left = p[2 * i];
      right = p[2 * i + 1];
      p[2 * i] = right;
      p[2 * i + 1] = left;
    }
  }
  cout << ans << endl;
  return 0;
}
