# ruiseki
from collections import Counter
F = open("/Users/yamataku/Downloads/subtask_1_09.txt")
# N = int(input())
# A_s = list(map(int,input().split()))
N = int(F.readline())
A_s = list(map(int,F.readline().split()))
ruiseki = [0]
for i,a in enumerate(A_s):
    ruiseki.append(ruiseki[i]+a)
counter = Counter(ruiseki)

answer = 0
for k,v in counter.items():
    if v > 1:
        answer += v * (v-1)//2
print(answer)