from collections import Counter

N = int(eval(input()))

A = [int(i) for i in input().split()]

cum = [0]

for a in A:

    cum.append(cum[-1] + a)

count = Counter(cum)

ans = 0

for v in list(count.values()):

    ans += v * (v - 1) // 2

print(ans)
from collections import Counter

N = int(eval(input()))

A = list(map(int, input().split()))

cum = [0]

for a in A:

    cum.append(cum[-1] + a)

count = Counter(cum)

ans = 0

for v in list(count.values()):

    ans += v * (v - 1) // 2

print(ans)

from collections import Counter

N = int(eval(input()))
A = [int(i) for i in input().split()]
cum = [0]
for a in A:
    cum.append(cum[-1] + a)
count = Counter(cum)
ans = 0
for v in list(count.values()):
    ans += v * (v - 1) // 2
print(ans)

from collections import Counter

N = int(eval(input()))
A = list(map(int, input().split()))
cum = [0]
for a in A:
    cum.append(cum[-1] + a)
count = Counter(cum)
ans = 0
for v in list(count.values()):
    ans += v * (v - 1) // 2
print(ans)

-A = [int(i) for i in input().split()] +A = list(map(int, input().split()))