import itertools

n = int(input())
ai = list(map(int, input().split()))

s = [0]
for i in range(n):
    s.append(s[i] + ai[i])

cnt = 0
for sj, si in itertools.combinations(s, 2):
    if si - sj == 0:
        cnt += 1

print(cnt)