n = int(input())
As = list(map(int, input().split()))
sum = [0]
for i in range(0, n):
    asum = sum[i] + As[i]
    sum.append(asum)
count = 0
for j in range(0, n+1):
    for l in range(j+1, n+1):
        if sum[j] == sum[l]:
            count += 1
print(count)