n = int(input())
list_a = list((map(int, input().split())))
memo = 0
memo_list = [0]
for i in range(0,n):
    memo += list_a[i]
    memo_list.append(memo)
#print(memo_list)
ans_pre_list = []
for number in set(memo_list):
    if memo_list.count(number) > 1:
        ans_pre_list.append(memo_list.count(number))
#print(ans_pre_list)
ans = 0
for number in ans_pre_list:
    ans += number * (number-1) / 2
print(int(ans))
