n = int(input())
s = list(map(int, input().rstrip().split()))

sum_list = []
for i in range(len(s) + 1):
    sum_list.append(sum(s[0:i]))

import collections
import itertools
c = collections.Counter(sum_list).values()

def comb(n,k):
    m = 1
    if n < 2 * k:
        k = n - k
    for i in range(1, k+1):
        m = m * (n - i + 1) // i
    return m

ans = 0
for i in c:
    if i >= 2:
        ans += comb(i,2)

print(ans)
