#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - 1e8;
const ll INFLL = numeric_limits<ll>::max() - 1e17;

int main() {
    int N;
    cin >> N;
    vector<int> P(N + 1);
    for (int i = 1; i <= N; i++) cin >> P[i];
    int left = 0, right = 0;
    vector<int> temp(N + 1);
    copy(P.begin(), P.end(), temp.begin());
    for (int i = 1; i < N; i++) if (temp[i] == i || temp[i + 1] == i + 1) {
        swap(temp[i], temp[i + 1]);
        left++;
    }
    copy(P.begin(), P.end(), temp.begin());
    for (int i = N; i > 1; i--) if (temp[i] == i || temp[i - 1] == i - 1) {
        swap(temp[i - 1], temp[i]);
        right++;
    }
    cout << min(left, right) << endl;
}
