N=int(eval(input()))

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

S=[0 for i in range(N+1)]

for i in range(N):

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

D=dict()

for i in range(N+1):

    x=D.get(S[i],0)

    x+=1

    D[S[i]]=x

ans=0

for k in D:

    ans+=(D[k]*(D[k]-1))//2

print(ans)

#平成の次の元号は

#令和です！！

#令和→零和→Zero-Sum

#この問題はZero-Sum-Ranges...

N=int(eval(input()))

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

S=[0 for i in range(N+1)]

for i in range(N):

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

D=dict()

for i in range(N+1):

    if S[i] in D:

        D[S[i]]+=1

    else:

        D[S[i]]=1

ans=0

for k in D:

    t=D[k]

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

print(ans)

N = int(eval(input()))
A = [int(i) for i in input().split()]
S = [0 for i in range(N + 1)]
for i in range(N):
    S[i + 1] = A[i] + S[i]
D = dict()
for i in range(N + 1):
    x = D.get(S[i], 0)
    x += 1
    D[S[i]] = x
ans = 0
for k in D:
    ans += (D[k] * (D[k] - 1)) // 2
print(ans)

# 平成の次の元号は
# 令和です！！
# 令和→零和→Zero-Sum
# この問題はZero-Sum-Ranges...
N = int(eval(input()))
A = [int(i) for i in input().split()]
S = [0 for i in range(N + 1)]
for i in range(N):
    S[i + 1] = A[i] + S[i]
D = dict()
for i in range(N + 1):
    if S[i] in D:
        D[S[i]] += 1
    else:
        D[S[i]] = 1
ans = 0
for k in D:
    t = D[k]
    ans += (t * (t - 1)) // 2
print(ans)

+# 平成の次の元号は +# 令和です！！ +# 令和→零和→Zero-Sum +# この問題はZero-Sum-Ranges... -    x = D.get(S[i], 0) -    x += 1 -    D[S[i]] = x +    if S[i] in D: +        D[S[i]] += 1 +    else: +        D[S[i]] = 1 -    ans += (D[k] * (D[k] - 1)) // 2 +    t = D[k] +    ans += (t * (t - 1)) // 2