N = int(input())
A = [int(i) for i in input().split()]

suml = [0] * (N+1)
tmp = 0
for i in range(1, N+1):
    tmp += A[i-1]
    suml[i] = tmp

ret = 0
for i in range(N+1):
    for j in range(i+1, N+1):
        if suml[j] == suml[i]:
            ret += 1

print(ret)
