# -*- coding: utf-8 -*-

max_length = 10e5


N = int(input())
A = input().split()
A = [int(a) for a in A]
S = [sum(A[:i]) for i in range(N+1)]
S.sort()
last = S[0]
c, count = 0, 0
for i in range(1, len(S)):
    if last != S[i]:
        if c > 0:
            c += 1
            count += int((c*(c-1)/2))
        last = S[i]
        c = 0
        continue
    elif i >= N:
        if last == S[i]:
            c += 1
        if c > 0:
            c += 1
            count += int((c*(c-1)/2))
    else:
        c += 1
print(count, end='')
