n = int(input())
a = list(map(int, input().split()))
s = [0] * (n+1)
for i in range(1, n+1):
    s[i] = s[i-1] + a[i-1]
ans = 0
for k in range(1, n):
    for i in range(n-k+1):
        if (s[i+k]-s[i]) == 0:
            ans += 1
print(ans)
