N = int(input())
A = list(int(i) for i in input().split())
B = []
B.append(0)
n = 1
cnt = 0

for i in A:
    B[0] += i
    B.append(B[0])
B[0] = 0
B.sort()

for i in range(1,N+1):
    if B[i] == B[i-1]:
        n += 1
    else:
        cnt += int(n*(n-1)/2)
        n = 1

cnt += int(n*(n-1)/2)6

print(cnt)