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

c = 0
for i in range(N):
    if i+1 == a[i] and i == N-1:
        c += 1
    elif i+1 == a[i]:
        a[i], a[i+1] = a[i+1], a[i]
        c += 1
cc = 0        
for i in range(N)[::-1]:
    if i+1 == b[i] and i == 0:
        cc += 1
    elif i+1 == b[i]:
        b[i], b[i-1] = b[i-1], b[i]
        cc += 1
        print(i)
        
print(min(c,cc))