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

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

for i in set(s):
    b = s.count(i)
    if b > 1:
        c += int(b*(b-1)/2)
print(c)
