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

ans = 0
sum = [0 for i in range(n+1)]

for i in range(1, n+1):
    sum[i] = sum[i-1] + a[i-1]

sum = sorted(sum)

for i in range(n):
    tmp = sum[i]
    for j in range(i, n+1):
        if i != j and tmp == sum[j]:
            ans += 1

print(ans)