import collections
n=int(input())
A=list(map(int,input().split()))
x=0
lst=[]
for i in range(n):
    x+=A[i]
    lst.append(x)
c=collections.Counter(lst)

 
def conv(n,m):
    if n==m or m==0:
        return 1
    else:
        return conv(n-1,m-1)+conv(n-1,m)
ans=0
for k in c.keys():
    if c[k]==0:
        continue
    if c[k]==1:
        if k==0:
            ans+=1
        else:
            continue
    elif k==0:
        ans+=c[k]+conv(c[k],2)
    else:
        ans+=conv(c[k],2)
print(ans)