n=input()
a=list(map(int, input().split(" ")))
count=0
if n==1:
    print(0)
else:
    for i in range(len(a)):
        num=a[i]
        for k in range(len(a)-(i+1)):
            num+=a[i+k+1]
            if num==0:
                count+=1
            #print(i,k)
            #if sum(a[i:i+k+2])==0:
            #    count+=1
    print(count)
