import sys
input=sys.stdin.readline

from math import factorial
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

N = int(input())
A = [0] + list(map(int, input().split()))

B = {}
for i in range(len(A)):
    x = sum(A[0:i+1])
    if x not in B:
        B[x] = 1
    else:
        B[x] += 1

ans = 0
for i in B.values():
    if i >= 2:
        ans += combinations_count(i,2)

print(ans)
