from collections import Counter

n = int(input())
a = list(map(int, input().split()))

l_sum = []
s= 0
for i in range(n):
    s += a[i]
    l_sum.append(s)

ans = 0
for i in range(n):
    if l_sum[i] == 0:
        ans += 1
    for j in range(i+1, n):
        if l_sum[i] == l_sum[j]:
            ans += 1

print(ans)