n = int(input())
data = list(map(int, input().split()))
ans1 = ans2 = 0

a = data.copy()
if a[0] == 1:
    w = a[0]
    a[0] = a[1]
    a[1] = w
    ans1 += 1
for i in range(1,n):
    if a[i] == i+1:
        w = a[i-1]
        a[i-1] = a[i]
        a[i] = w
        ans1 += 1

a = data.copy()
#print(a)
if a[n-1] == n:
    w = a[n-1]
    a[n-1] = a[n-2]
    a[n-2] = w
    ans2 += 1
for i in range(n-2,-1,-1):
    if a[i] == i+1:
#        print (i)
        w = a[i+1]
        a[i+1] = a[i]
        a[i] = w
        ans2 += 1
#print(ans1, ans2)
print(min(ans1,ans2))
