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

cnt = 0
for i in range(len(A)-1):
    S = A[i]
    for j in range(i+1, len(A)):
        S += A[j]
        if(S == 0):
            cnt += 1
print(cnt)