n = int(eval(input()))

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

S = [0]*(n+1)

num = {}

for i in range(n):

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

for i in S:

    s = str(i)

    num[s] = 1 if s not in list(num.keys()) else num[s]+1

out = [i*(i-1)//2 for i in list(num.values()) if i > 1]

print((sum(out)))
from collections import Counter

n = int(eval(input()))

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

S = [0]*(n+1)

for i in range(n):

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

out = [i*(i-1)//2 for i in list(Counter(S).values()) if i > 1]

print((sum(out)))
n = int(eval(input()))
A = [int(i) for i in input().split()]
S = [0] * (n + 1)
num = {}
for i in range(n):
    S[i + 1] = S[i] + A[i]
for i in S:
    s = str(i)
    num[s] = 1 if s not in list(num.keys()) else num[s] + 1
out = [i * (i - 1) // 2 for i in list(num.values()) if i > 1]
print((sum(out)))

from collections import Counter

n = int(eval(input()))
A = [int(i) for i in input().split()]
S = [0] * (n + 1)
for i in range(n):
    S[i + 1] = S[i] + A[i]
out = [i * (i - 1) // 2 for i in list(Counter(S).values()) if i > 1]
print((sum(out)))

+from collections import Counter + -num = {} -for i in S: -    s = str(i) -    num[s] = 1 if s not in list(num.keys()) else num[s] + 1 -out = [i * (i - 1) // 2 for i in list(num.values()) if i > 1] +out = [i * (i - 1) // 2 for i in list(Counter(S).values()) if i > 1]