N = int(input()) P = [0]+list(map(int,input().split())) ans = -10**9 A = [0]*(N+1) cnt = 0 for i in range(1,N+1): if P[i]