n = int(input())
a = [int(i) for i in input().split()]

a_ = [0]

for i in range(n):
    a_.append(a_[i] + a[i])

cnt = 0
x = []

for i in a_:
    if i in x:
        cnt += x.count(i)
    x.append(i) 

print(cnt)