from itertools import accumulate
from collections import Counter
import sys
sys.setrecursionlimit(10**9)
input=sys.stdin.readline
n=int(input())
A=list(map(int,input().split()))
S=list(accumulate(A))
C=Counter(S)

def num(m):
    return m*(m-1)//2

ans=0
for k,v in C.items():
    if k==0:
        ans+=v
    if v>1:
        ans+=comb(v)
print(ans)