#include <iostream>
using namespace std;

int main(){
    int n, i, buf, m=-1, c=0;
    cin >> n;
    for(i=0; i<n; i++){
        cin >> buf;
        if(m == -1 && buf == i){
            m = buf;
        }else if(m!=-1 && buf == i{
            c += buf - m;
        }
    }
    cout << min(c, n-c-1);
    return 0;
}