n = int(input())
l = list(map(int,input().split()))
rui_l = [0]
tmp = 0
res = 0

for i in range(n):
    rui_l.append(l[i]+tmp)
    tmp = rui_l[-1]

for i in set(rui_l):
    c = rui_l.count(i)
    if c > 0:
        res += c*(c-1)//2
else:
    print(res)
        