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

ans = 0
flag = False
for i in range(N - 1):
    if flag:
        n = p[i+1]
    else:
        n = p[i]
    if n == i+1:
        ans += 1
        flag = True
    else:
        flag = False
if flag:
    n = p[-2]
else:
    n = p[-1]
if n == N:
    ans += 12
print(ans)