N = int(input()) A = list(map(int, input().split())) ans = 1 lis = [True]+[False]*(N-1) for i in range(1,N): if A[i-1]