N = int(input())
A = list(map(int, input().split()))

sig = {0:0}
m = 0
for i in A:
    m += i
    if m not in sig:
        sig[m] = 0
    else:
        sig[m] += 1


ans = 0
for i in sig.values():
    ans += i*(i+1)//2

print(ans)
