# A - Zero-Sum Ranges
import numpy as np

N = int(input())
A = list(map(int, input().split()))
S = np.zeros(N)
ans = 0

for j in range(N):
    for i in range(N-j):
        S[i] += A[i+j]
        ans += int(S[i]==0)

print(ans)