n = int(input())
a = []
a = list(map(int,input().split(' ')))

#print(a)
tsumset = []
tsumset.append(0)
tsum = 0
cnt = 0

for i in range(len(a)):
    tsum += a[i]
    if tsum in tsumset:
        cnt+=tsumset.count(tsum)
    
    tsumset.append(tsum)

print(cnt)
