n = int(input())
A = list(map(int, input().split()))
acc = [0] * (n + 1)
for i in range(n):
    acc[i + 1] = acc[i] + A[i]

cnt = 0
for i in range(2, n + 1):
    for j in range(1, i):
        sub_sum = acc[i] - acc[j - 1]
        if sub_sum == 0:
            cnt += 1
print(cnt)