import itertools N = int(input()) A = list(map(int, input().split())) L = [0]*N ans = 1 for i in range(1,N): if A[i-1]