N = int(input())
A = [int(i) for i in input().split()]

count = 0

dp = [["*" for i in range(N)] for j in range(N)]
#print(dp)
dp[0][0] = A[0]
if dp[0][0] == 0:
    count += 1
    
for j in range(1,N):
    dp[0][j] = dp[0][j-1] + A[j]
    if dp[0][j] == 0:
        count += 1

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

#print(dp)

print(count)