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

ans = 0
for i in range(n):
    for j in range(i+1, n):
        if p[j-1] == j:
            p[j-1], p[j] = p[j], p[j-1]
            ans += 1

print(ans)