N = int(eval(input()))

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



S = [0]



for i in range(len(A)):

    S.append(S[-1] + A[i])





counter = {}



for i in range(len(S)):

    counter.setdefault(S[i], 0)

    counter[S[i]] += 1



ans = 0

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

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



print(ans)

from collections import Counter

N = int(eval(input()))  # 長さN

A = list(map(int, input().split()))  # 整数列A



S = [0]

for i in range(len(A)):

    S.append(S[-1] + A[i])



c = Counter(S)



ans = 0

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

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



print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
S = [0]
for i in range(len(A)):
    S.append(S[-1] + A[i])
counter = {}
for i in range(len(S)):
    counter.setdefault(S[i], 0)
    counter[S[i]] += 1
ans = 0
for v in list(counter.values()):
    ans += (v * (v - 1)) // 2
print(ans)

from collections import Counter

N = int(eval(input()))  # 長さN
A = list(map(int, input().split()))  # 整数列A
S = [0]
for i in range(len(A)):
    S.append(S[-1] + A[i])
c = Counter(S)
ans = 0
for v in list(c.values()):
    ans += v * (v - 1) // 2
print(ans)

-N = int(eval(input())) -A = list(map(int, input().split())) +from collections import Counter + +N = int(eval(input()))  # 長さN +A = list(map(int, input().split()))  # 整数列A -counter = {} -for i in range(len(S)): -    counter.setdefault(S[i], 0) -    counter[S[i]] += 1 +c = Counter(S) -for v in list(counter.values()): -    ans += (v * (v - 1)) // 2 +for v in list(c.values()): +    ans += v * (v - 1) // 2