n = int(input())
a = list(map(int,input().split()))
ans = 0
ans += a.count(0)
for i in range(2,n+1):
    tmp = []
    x = 0
    for j in range(i):
        x += a[j]
    if x == 0:
        ans += 1
    for k in range(n - i):
        x += a[k + i] - a[k]
        if x == 0:
            ans += 1
print(ans)        
