import math
N = int(input())
AAA = [int(i) for i in input().split()]
BBB = [0]
for a in AAA:
    BBB.append(a+BBB[-1])
ans=[]
#print(BBB)
BBB=sorted(BBB)
#print(BBB)
prev = math.inf
buff=BBB[0]
ans=[]
for i,b in enumerate(BBB):
    #print(b,prev,buff)
    if b==prev:
        buff+=1
    else:
        if buff>=2:
            #print("append!")
            ans.append(buff)
        buff=1
        prev=b
if buff!=1:
    ans.append(buff)
#print(ans)
print(sum([(i-1)*i//2 for i in ans]))