n = int(input()) a = list(map(int,input().split())) ans = 0 i = 0 j = 1 while i+j a[i+j]: ans += 1 j += 1 else: i += j j = 1 print(ans)