from collections import Counter
from math import factorial
N=input()
A=map(int, raw_input().split())
b=[]

def product(iterable):
    prod = 1
    for n in iterable:
        prod *= n
    return prod

def npr(n, r):
    return product(range(n - r + 1, n + 1))

def ncr(n, r):
    if r > n // 2:
        r = n - r
    return npr(n, r) // factorial(r)

A_sum=0
for i in A:
	A_sum+=i
	b.append(A_sum)

c=Counter(b)

ans=0
for i,j in c.items():
	if i==0:
		ans+=ncr(j+1,2)
	elif j>=2:
		ans+=ncr(j,2)
		
print ans
