N = int(input())

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



ans, s = 0, 0

d = {0:1}



for i in A:

    s += i

    ans += d.get(s, 0)

    d[s] = d.get(s, 0) + 1



print(ans)
#!/usr/bin/env python3



from collections import defaultdict



N = int(eval(input()))

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



d = defaultdict(int)

d[0] = 1



s, ans = 0, 0



for a in A:

    s += a

    ans += d[s]

    d[s] += 1



print (ans)
N = int(input())
A = list(map(int, input().split()))
ans, s = 0, 0
d = {0: 1}
for i in A:
    s += i
    ans += d.get(s, 0)
    d[s] = d.get(s, 0) + 1
print(ans)

#!/usr/bin/env python3
from collections import defaultdict

N = int(eval(input()))
A = list(map(int, input().split()))
d = defaultdict(int)
d[0] = 1
s, ans = 0, 0
for a in A:
    s += a
    ans += d[s]
    d[s] += 1
print(ans)

-N = int(input()) +#!/usr/bin/env python3 +from collections import defaultdict + +N = int(eval(input())) -ans, s = 0, 0 -d = {0: 1} -for i in A: -    s += i -    ans += d.get(s, 0) -    d[s] = d.get(s, 0) + 1 +d = defaultdict(int) +d[0] = 1 +s, ans = 0, 0 +for a in A: +    s += a +    ans += d[s] +    d[s] += 1