from itertools import accumulate
N = int(input())
A = list(map(int, input().split()))

lst = sorted(list(accumulate(A)))
lst.insert(0, 0)

t =1
count= 0
for i in range(N):
    if lst[i] == lst[i+1]:
        t += 1
    else:
        count += t*(t-1)//2
        t = 1
count += t*(t-1)//2
print(count)