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

sumli = [0]
sum = 0
acum = 0

for i in ali:
    sum = sum + i
    sumli.append(sum)

sumtally =[sumli.count(x) for x in set(sumli)]

for j in sumtally:
    acum = acum+(j*(j-1))//2

print(acum)
