n = int(input())
dat = list(map(int, input().split()))
buf = [0] * (n+1)
buf.append(0)
cur = 0
for i in range(0, n):
    cur += dat[i]
    buf[i+1] = cur

#print(buf)

res = 0
for i in range(0, n+1):
    for j in range(i + 1, n+1):
        if buf[i] == buf[j]:
            res += 1
print(res)
