import numpy as np
from collections import Counter
def f(lst):
    return np.cumsum(lst)

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

res = 0
for i in range(n):
    tmp_lst = lst[i:]
    c = dict(Counter(f(tmp_lst)))
    if 0 in c:
       res += c[0]
print(res)
