from itertools import combinations
N = int(input())
A = list(map(int, input().split()))
memo = [0]*(N+1)
for i in range(1, N+1):
    memo[i] = memo[i-1] + A[i-1]

cnt = 0
for c in combinations(memo, 2):
    if c[0] == c[1]:
        cnt += 1

print(cnt)