import numpy as np
from sys import stdin
N=int(stdin.readline().rstrip())
data=[int(x) for x in stdin.readline().rstrip().split()]
res = np.cumsum(data)
res=np.insert(res,0,0)
cnt=1
ans=0
tmp=float("inf")
ite=np.append(sorted(res),0)
for j in ite:
    if j == tmp:
        cnt+=1
    else:
        ans=ans+((cnt*(cnt-1))/2)
        cnt=1
    tmp=j
print(int(ans))