#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
int n, ret = 0;
vector<int> p;
inline void pswap(int i, int j) {
  int tmp = p[i] + 1;
  p[i] = p[j] - 1;
  p[j] = tmp;
}
int swap(int left, int right) {
  int cnt = 0;
  for (int i = left; i < right; i++) {
    pswap(left, left + 1);
    cnt++;
  }
  return cnt;
}
int main(void) {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int pi;
    cin >> pi;
    p.push_back(pi - i - 1);
  }
  for (int i = 0; i < n; i++) {
    if (p[i] == 0) {
      bool flag = false;
      for (int j = 1; j < n && !flag; j++) {
        if (!flag && i - j >= 0) {
          if (p[i - j] != -1 * j) {
            flag = true;
            ret += swap(i - j, i);
          }
        } else if (!flag && i + j < n) {
          if (p[i + j] != j) {
            flag = true;
            ret += swap(i, i + j);
          }
        }
      }
    }
  }
  cout << ret << endl;
  return 0;
}
