N = int(input())

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

s = 0

subsum = [0]

ans = 0

for a in A:
    s += a
    subsum.append(s)

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

print(ans)