from itertools import accumulate
from collections import Counter


n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    a_acc = Counter(accumulate(a[i:]))
    if 0 in a_acc.keys():
        ans += a_acc[0]
print(ans)