N = int(input())
A = list(map(int, input().split()))
S = [0]*(N+1)
for n in range(N):
    S[n+1] = S[n] + A[n]
cnt = 0
for s in range(len(S)):
    for i in range(len(S)):
        if s < i and S[s] == S[i]:
            cnt +=1
print(cnt)