n = int(input())
number_list = list(map(int,input().split()))
counter = 0
if n == 1:
    if number_list[0] == 0:
        print(1)
    else:
        print(0)
else:
    #iが開始位置
    for i in range(n):
        #連続数
        for j in reversed(range(n)):
            if i+j < n:
                sum_number = sum(number_list[i:i+j+1])
                if sum_number == 0:
                    counter += 1

    print(counter)
