n=int(input()) ns=list(map(int,input().split())) m=[0]*(n-1) ma=0 for i in range(n-1): ma=max(ns[i],ma) m[i] = ma now=m[0] cnt=1 while now != n: now = m[now-1] cnt+=1 print(cnt)