n = int(input())
A = [int(i) for i in input().split()]
S = [sum(A[:i]) for i in range(n+1)]
# num = [S.count(i) for i in set(S)]

from collections import Counter
def hello(bm):
    dt = Counter()
    for i in bm:
        key = str(i)
        dt[key] += 1
    return dt

num = hello(S)
out = [i*(i-1)//2 for i in num.values() if i>1]
print(sum(out))