import collections

n =int(input())
a = list(map(int,input().split()))
s = [0]
for i in range(n):
    s.append(s[i]+a[i])

cs = list(collections.Counter(s).values())
res = 0
for scs in cs:
    res += scs * (scs-1)//2

print(res)