N = int(input())
A = {0:1}
total = 0
count = 0
for a in input().split():
    total += int(a)
    if total in A:
        count += A[total]
        A[total] += 1
    else:
        A[total] = 1
print(count)