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

count = 0
numbers = []
for i in A:
    numbers = [j + i for j in numbers]
    numbers.append(i)
    count += numbers.count(0)

print(count)