from math import factorial as f

def nCr(n, r):
    return int(f(n) / (f(r) * f(n-r)))
    
N = int(input())
lisA = list(map(int, input().split()))

lisB = [0]
m = 0
for e in lisA:
    m += e
    lisB.append(m)

lisRed = [nCr(lisB.count(e), 2) for e in set(lisB) if lisB.count(e) > 1]
ans = sum(lisRed)

print(ans)
