#include <bits/stdc++.h>
using namespace std;
struct Queue_data {
  long long len;
  vector<long long> p;
};
int main() {
  long long ans = LLONG_MAX;
  long long N;
  cin >> N;
  vector<long long> p;
  p.resize(N);
  for (long long i = 0; i < N; i++) {
    cin >> p[i];
  }
  bool flag = true;
  for (long long i = 0; i < N - 1; i++) {
    if (p[i] == i + 1) {
      long long tmp = p[i];
      p[i] = p[i + 1];
      p[i + 1] = tmp;
    }
  }
  if (p[N - 1] == N) {
    long long tmp = p[N - 1];
    p[N - 1] = p[N - 2];
    p[N - 2] = tmp;
  }
  cout << ans << endl;
  return 0;
}
