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)

while len(sumli)!=0:
    s=sumli[0]
    ss=sumli.count(s)
    acum = acum+(ss*(ss-1))//2
    for x in range(ss):
        sumli.remove(s)

print(acum)
