# -*- coding: utf-8 -*-
"""
Contents   : AtCoder Grand Contest 023
Author     : Kitaura Hiromi
LastUpdate : 20180502
Since      : 20180428
"""
N = int(input())
A = list(map(int, input().split(" ")))

"""
# O(N^2)
cnt = 0
for i in range(N):
    for j in range(i+1, N+1):
        if sum(A[i:j]) == 0:
            cnt += 1
print(cnt)
"""

# O(NlogN)
S = []
for i in range(N+1):
    S.append(sum(A[:i]))
S = sorted(S)
cnt = 1
ret = 0
tmp = S[0]
for i in range(1, len(S)):
    if tmp == S[i]:
        cnt += 1
    else:
        ret += cnt * (cnt - 1) // 2
        cnt = 1
        tmp = S[i]
ret += cnt * (cnt - 1) // 2
print(ret)