#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, answer = 0, even = 0, odd = 0;
  cin >> N;
  int p[N];
  map<int, int> invalid;
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }
  if (p[0] == 1) {
    answer++;
    swap(p[0], p[1]);
  }
  if (N % 2 && p[N - 1] == N) {
    answer++;
    swap(p[N - 2], p[N - 1]);
  }
  for (int i = 1; i < N; i += 2) {
    odd += p[i] == i + 1;
  }
  for (int i = 2; i < N; i += 2) {
    even += p[i] == i + 1;
  }
  answer += max(odd, even);
  cout << answer;
}
