from collections import defaultdict
d = defaultdict(int)
N = int(input())
A = [int(x) for x in input().split()]
cumu=[0]
d[0]+=1
for i in A:
    cumu.append(cumu[-1]+i)
    d[cumu[-1]]+=1

print(sum(d.values())-len(d))
