from itertools import accumulate
from collections import Counter


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

s = 0
for j in range(n):
    l = list(accumulate(a[j:]))
    c = Counter(l)
    s += c[0]

print(s)