import collections

N=int(eval(input()))

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

b=ans=0

c=collections.Counter([0])

for a in A:

  b+=a

  ans+=c[b]

  c[b]+=1

print(ans)
from collections import Counter

N=int(eval(input()))

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

S=[0]*N

for i in range(N):

  S[i]=S[i-1]+A[i]

S=[0]+S

S=Counter(S)

a=[S[s]*(S[s]-1)//2 for s in S]

print((sum(a)))
import collections

N = int(eval(input()))
A = list(map(int, input().split()))
b = ans = 0
c = collections.Counter([0])
for a in A:
    b += a
    ans += c[b]
    c[b] += 1
print(ans)

from collections import Counter

N = int(eval(input()))
A = list(map(int, input().split()))
S = [0] * N
for i in range(N):
    S[i] = S[i - 1] + A[i]
S = [0] + S
S = Counter(S)
a = [S[s] * (S[s] - 1) // 2 for s in S]
print((sum(a)))

-import collections +from collections import Counter -b = ans = 0 -c = collections.Counter([0]) -for a in A: -    b += a -    ans += c[b] -    c[b] += 1 -print(ans) +S = [0] * N +for i in range(N): +    S[i] = S[i - 1] + A[i] +S = [0] + S +S = Counter(S) +a = [S[s] * (S[s] - 1) // 2 for s in S] +print((sum(a)))