import numpy as np

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


#
#for i in range(N):
#    Sum[i] = Sum[i-1] + A[i]

count = 0
S = np.zeros(N)


for i in range(N):
    for j in range(i+1):
        S[j] = S[j] + A[i]
        if S[j] == 0:
            count += 1
#    Sum[i] = A[i]
#    S = A[i]
#    if S == 0:
#        count += 1
#    for j in range(i+1, N):
#        S += A[j]
#        if S == 0:
#            count += 1
            
print(count)