N = int(input())

A = [0] + [a for a in map(int, input().split())]

for i in range(N):
    A[i+1] += A[i]
A.sort()
temp = A[0]
cnt = 0
ans = 0
if N == 1:
    print(0)
else:
    for a in A:
        if temp == a:
            cnt += 1
        else:
            ans += cnt *(cnt-1) // 2
            cnt = 1
            temp = a
ans += cnt * (cnt-1) // 2

print(int(ans))
