#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  return b ? gcd(b, a % b) : a;
}
long long int power(long long int a, long long int b) {
  long long int ans = 1;
  while (b) {
    if (b & 1) {
      ans = (ans * a) % 1000000007;
    }
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int i, j, k, l;
  long long int n;
  cin >> n;
  vector<long long int> v, v2;
  for (i = 0; i < n; i++) {
    cin >> j;
    v.push_back(j);
  }
  for (i = 0; i < n; i++) {
    if (v[i] == i + 1) {
      v2.push_back(i + 1);
    }
  }
  if (v2.size() == 0)
    cout << "0\n";
  else if (v.size() == 1)
    cout << "1\n";
  else {
    k = 0;
    for (i = 0; i < v2.size(); i += 2) {
      k += (v2[i + 1] - v2[i]);
    }
    if (v2.size() % 2 == 1) k += 1;
    l = 0;
    for (i = v2.size() - 1; i >= 0; i -= 2) {
      l += (v2[i] - v2[i - 1]);
    }
    if (v2.size() % 2 == 1) l += 1;
    cout << min(l, k) << "\n";
  }
  return 0;
}
