#include <bits/stdc++.h>

using namespace std;

int N, a[100005], sol, fcv[100005];
vector < int > pos;

int main() {
    ios_base::sync_with_stdio(false);
    cin >> N;
    for (int i = 1; i <= N; ++i) {
        cin >> a[i];
        
        if (a[i] == i) {
            pos.push_back(i);
        }
    }
    
    int ok = 1;
    while (ok) {
        ok = 0;
        for (int i = 1; i <= N; ++i) {
            if (a[i] == i) {
                if (i == 1) {
                    swap(a[i], a[i + 1]);
                    ++sol;
                    ok = 1;
                    continue;
                }
                
                if (i == N) {
                    swap(a[i], a[i - 1]);
                    ++sol;
                    ok = 1;
                    continue;
                }
                
                if (a[i - 1] != i - 1) {
                    swap(a[i], a[i - 1]);
                    ++sol;
                    ok = 1;
                } else if (a[i + 1] != i + 1) {
                    swap(a[i], a[i + 1]);
                    ++sol;
                    ok = 1;
                }
            }
        }
    }
    
    cout << sol << '\n';
    return 0;
}