n = int(input())
a = list(map(int, input().split()))
s = [0]
b = c = 0
i = j = 0

for i in range(n):
    s.append(s[i] + a[i])
s.sort()

for i in set(s):
    for j in s:
        if i == j:
            b += 1
    c += int(b*(b-1)/2)
    b = 0

print(c)
