import sys

N = int(input())
A =  list(map(int,input().split()))

res = 0
s = 0
s_list = [[0,0]]
i = 0
while i < N:
    s += A[i]
    inside = True
    j = 0
    while j < len(s_list):
        if s == s_list[j][1]:
            s_list[j][0] += 1
            inside = False
            j = len(s_list) + 1
        j += 1
    if inside:
        s_list.append([0,s])
    i += 1
for s in s_list:
    res += s[0] * (s[0] + 1) / 2.
    
print(int(res))