from itertools import accumulate


N=int(input())
A=list(map(int,input().split()))
sums=list(accumulate([0]+A))
def nCr(n,r):
    a=factorial(n)
    b=factorial(n-r)
    c=factorial(r)
    return int(a//(b*c))
dic=defaultdict(int)
for i in sums:
    dic[i]+=1
ans=0
for i in dic.keys():
    if dic[i]>=2:
        ans+=nCr(dic[i],2)
print(ans)
