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
c = collections.Counter(sum_list).values()

ans = 0
for i in c:
    if i >= 2:
        ans += i * (i - 1) // 2

print(ans)