N = int(input()) A = [0]+list(map(int,input().split())) indA = [0]*(N+1) flagA = [0]*(N+1) for i in range(1,N+1): indA[A[i]] = i cnt = 0 for k in range(1,N+1): ind = indA[k] if flagA[ind]==0: cnt += 1 flagA[ind] = 1 if ind>1: flagA[ind-1] = 1 print(cnt)