N=int(input())
p=list(map(int,input().split()))
q=['x' for _ in range(N)]
ans=0
for i in range(N):
    if p[i]!=i+1:
        q[i]='o'
for i in range(N-1):
    if q[i]=='x':
        p[i], p[i+1]=p[i+1], p[i]
        ans+=1
    for j in range(N):
        if p[j]!=j+1:
            q[j]='o'
print(ans)
