n = int(input())
a = [int(i) for i in input().split()]
b = [0] * (n)
b[0] = a[0]
for i in range(1, n):
    b[i] = b[i-1] + a[i]
ans = 0
for i in range(n):
    for j in range(i+1, n):
        if b[j] - b[i] == 0:
            ans += 1
ans += b.count(0)
print(ans)