n = int(input())
a = list(map(int, input().split()))
s = [0]
for i in range(n):
    s.append(s[-1] + a[i])
s_uniq = list(set(s))
result = 0
 
for s_uniq_i in s_uniq:
    count = s.count(s_uniq_i)
    if count >= 2:
        result += count * (count-1) // 2
 
print(result)