from itertools import accumulate
n = int(input())
A = [0]+list(accumulate(map(int,input().split())))
ans = 0
for i in range(1,n+1):
    for j in range(n+1-i):
        if A[j+i]-A[j] == 0:
            ans += 1
print(ans)