import collections
import math

N = input()

A = [int(i) for i in raw_input().split()]

ruiseki = [0]

sum_ = 0

for i in range(N):
    sum_ += A[i]
    ruiseki.append(sum_)


c = collections.Counter(ruiseki)
#print(c)

ret = 0


for k, v in c.items():
    if(v>1):
        ret += v * (v-1) /2
 #       print(k,v,ret)

print(ret)
