N = int(input())
A = list(map(int, input().split()))
count = 0

count = A.count(0)
A = [n for n in A if n != 0]

for i in range(N):
    num = A[i]
    for Aj in A[i+1:]:
        num += Aj
        if num == 0:
            count += 1

print(count)