#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int p[n];
    for(int i=0;i<n;i++)cin >> p[i];
    int ans=0;
    int tmp=0;
    if(n%2==0){
        for(int i=0;i<n-1;i+=2)if(p[i]==i+1 || p[i+1]==i+2)ans++;
        if(a[0]!=1 && a[n-1]!=n)for(int i=1;i<n-1;i+=2)if(p[i]==i+1 || p[i+1]==i+2)tmp++;
        ans=min(ans,tmp);
    }
    else{
        if(p[n-1]!=n)for(int i=0;i<n-2;i+=2)if(p[i]==i+1 || p[i+1]==i+2)ans++;
        if(p[0]!=1)for(int i=1;i<n-1;i+=2)if(p[i]==i+1 || p[i+1]==i+2)tmp++;
       ans=min(ans,tmp);
    }    
    cout << ans;
}