n = int(input())
p = list(map(int,input().split()))
res = 0
for a in [p,p[::-1]]:
    tmp = 0
    for i in range(n-1):
        if a[i]==i+1 or a[i+1]==i+2:
            tmp += 1
            a[i],a[i+1] = a[i+1],a[i]
    res = min(res,tmp)
print(res)
