from itertools import accumulate

from collections import defaultdict

N = int(eval(input()))

As = [0]+list(map(int, input().split()))

Acc = list(accumulate(As))



d = defaultdict(int)

for a in Acc:

    d[a] += 1

ans = 0

for k in list(d.keys()):

    n = d[k]

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

print(ans) 
from itertools import accumulate

from collections import defaultdict

n = int(eval(input()))

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



acc = [0]+list(accumulate(As))

d = defaultdict(int)

for a in acc:

    d[a] += 1

ans = 0

for k in list(d.keys()):

    n = d[k]

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

print(ans)
from itertools import accumulate
from collections import defaultdict

N = int(eval(input()))
As = [0] + list(map(int, input().split()))
Acc = list(accumulate(As))
d = defaultdict(int)
for a in Acc:
    d[a] += 1
ans = 0
for k in list(d.keys()):
    n = d[k]
    ans += n * (n - 1) // 2
print(ans)

from itertools import accumulate
from collections import defaultdict

n = int(eval(input()))
As = list(map(int, input().split()))
acc = [0] + list(accumulate(As))
d = defaultdict(int)
for a in acc:
    d[a] += 1
ans = 0
for k in list(d.keys()):
    n = d[k]
    ans += n * (n - 1) // 2
print(ans)

-N = int(eval(input())) -As = [0] + list(map(int, input().split())) -Acc = list(accumulate(As)) +n = int(eval(input())) +As = list(map(int, input().split())) +acc = [0] + list(accumulate(As)) -for a in Acc: +for a in acc: