from collections import *

from itertools import *



N=int(eval(input()))

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



s1=[0]+list(accumulate(A))

nums=defaultdict(int)

for i in range(N+1):

  nums[s1[i]]+=1



ans=0

s2=set(s1)

for x in s2:

  ans+=nums[x]*(nums[x]-1)//2



print(ans)

from collections import *

from itertools import *



N=int(eval(input()))

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



s=[0]+list(accumulate(A))

s_cnt=Counter(s)



ans=0

for x in list(s_cnt.values()):

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



print(ans)

from collections import *
from itertools import *

N = int(eval(input()))
A = list(map(int, input().split()))
s1 = [0] + list(accumulate(A))
nums = defaultdict(int)
for i in range(N + 1):
    nums[s1[i]] += 1
ans = 0
s2 = set(s1)
for x in s2:
    ans += nums[x] * (nums[x] - 1) // 2
print(ans)

from collections import *
from itertools import *

N = int(eval(input()))
A = list(map(int, input().split()))
s = [0] + list(accumulate(A))
s_cnt = Counter(s)
ans = 0
for x in list(s_cnt.values()):
    ans += (x * (x - 1)) // 2
print(ans)

-s1 = [0] + list(accumulate(A)) -nums = defaultdict(int) -for i in range(N + 1): -    nums[s1[i]] += 1 +s = [0] + list(accumulate(A)) +s_cnt = Counter(s) -s2 = set(s1) -for x in s2: -    ans += nums[x] * (nums[x] - 1) // 2 +for x in list(s_cnt.values()): +    ans += (x * (x - 1)) // 2