#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int p[n];
  for (int i = 0; i < n; ++i) cin >> p[i];
  int c = 0, bc = 0;
  while (1) {
    if (p[0] == 1) {
      swap(p[0], p[1]);
      c++;
    }
    for (int i = 1; i < n + 1; ++i) {
      if (p[i] == i + 1) {
        swap(p[i], p[i - 1]);
        c++;
      }
    }
    if (bc == c) break;
    bc = c;
  }
  cout << c << endl;
}
