N = int(input())
a = list(map(int, input().split()))
S = [0]

for num in a:
    S.append(S[-1] + num)

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

print(ans)