n = int(input())
a = list(map(int, input().split()))
s = [sum(a[0:i+1]) for i in range(n)]
result = 0

for i in range(n):
    if s[i] == 0:
        result += 1
    for j in range(i+1, n):
        if s[j] - s[i] == 0:
            result += 1

print(result)