from math import factorial


def combination(n, r):  # n個からr個選ぶ場合の数
    if n < r:
        return 0
    else:
        return factorial(n)//(factorial(r) * factorial(n-r))


from itertools import accumulate
N = int(input())
A = [int(i) for i in input().split()]
cumsum = list(accumulate(A))
ans = 0
for a in set(cumsum):
    cnt = 0
    for c in cumsum:
        if a == c:
            cnt += 1
    ans += combination(cnt, 2)
ans += 0
print(ans)
