n = int(input())
a = list(map(int, input().split()))

s=[0]
sm=0
for i in a:
    sm+=i
    s.append(sm)
s.sort()
import collections
c = collections.Counter(s)
from math import factorial
def ncr(n,r):
    return factorial(n) / factorial(r) / factorial(n - r)
ans=0
for v in c.values():
    if v>1:
        ans+=ncr(v,2)

print(int(ans))