N=int(input())
p=list(map(int,input().split()))

if N%2==0:
    a=[p[j:j+2] for j in range(0,N-1,2)]
    ans=0
    for i in range(len(a)):
     if (a[i][0]==(2*i+1)) or (a[i][1]==2*i+2):
        ans += 1
     else:
        pass
    print(ans)
elif p[N-1]!=N:
    a=[p[j:j+2] for j in range(0,N-1,2)]
    ans=0
    for i in range(len(a)):
     if (a[i][0]==(2*i+1)) or (a[i][1]==2*i+2):
        ans += 1
     else:
        pass
    print(ans)
elif p[0]!=1:
    a=[p[j:j+2] for j in range(1,N,2)]
    ans=0
    for i in range(1,len(a)+1):
     if (a[i][0]==(2*i)) or (a[i][1]==2*i+1):
        ans += 1
     else:
        pass
    print(ans)
elif p[2]==3:
    a=[p[j:j+2] for j in range(3,N,2)]
    ans=2
    for i in range(len(a)):
     if (a[i][0]==(2*i+4)) or (a[i][1]==2*i+5):
        ans += 1
     else:
        pass
    print(ans)
else:
    a=[p[j:j+2] for j in range(3,N,2)]
    ans=1
    for i in range(len(a)):
     if (a[i][0]==(2*i+4)) or (a[i][1]==2*i+5):
        ans += 1
     else:
        pass
    print(ans)
