n = int(input())
dat = list(map(int, input().split()))
buf = [0] * (n+1)
cur = 0
import collections
pos = collections.defaultdict(list)
 
for i in range(0, n):
    cur += dat[i]
    pos[cur].append(i)
    buf[i+1] = cur
 
 
#print(buf)
#print(pos)
 
import bisect
res = 0
for i in range(0, n+1):
    ind = bisect.bisect_right(pos[buf[i]], i)
    res += len(pos[buf[i]]) - ind
print(res)