N=int(input())
A=list(map(int,input().split()))

count=0

SUM=["" for i in range(N)]
SUM[0]=A[0]

for i in range(1,N):
    SUM[i] = SUM[i-1]+A[i]

for i in range(N):
    if SUM[i]==0:
        count=count+1

for i in range(1,N):
    for j in range(i-1):
        if SUM[i]-SUM[j]==0:
            count=count+1


print(count)
