n = int(input())
nums = input()
A =[int(x.strip()) for x in nums.split()]

ans = 0
for i in range(n):
    for j in range(n-i):
        splited = A[i:i+j+1]
        # print(splited,i,j)
        goukei = sum(splited)
        if goukei == 0 and splited != []:
            # print(splited)
            ans += 1

print(ans)