from math import factorial

n = int(input())
a = list(map(int, input().split()))
s = [0]
s.extend([sum(a[0:i+1]) for i in range(n)])
s_uniq = list(set(s))
result = 0

for s_uniq_i in s_uniq:
    count = s.count(s_uniq_i)
    if count >= 2:
        result += int( factorial(count) / (factorial(count-2) * factorial(2)) )

print(result)