import collections

N = int(eval(input()))

A = [int(i) for i in input().split()]



S = [0] * (N+1)

for k in range(1,N+1):

  S[k] = S[k-1] + A[k-1]



count = collections.Counter(S)

ans = 0

for k,v in list(count.items()):

  ans += v * (v-1) // 2

print(ans)
def a_zero_sum_ranges(N, A):

    import collections

    import itertools

    # s[l]==s[r] のとき、A[l+1]+...+A[r] == 0 となる

    s = itertools.accumulate([0] + A)

    count = collections.Counter(s)

    ans = 0

    for k, v in list(count.items()):

        ans += v * (v - 1) // 2

    return ans



N = int(eval(input()))

A = [int(i) for i in input().split()]

print((a_zero_sum_ranges(N, A)))
import collections

N = int(eval(input()))
A = [int(i) for i in input().split()]
S = [0] * (N + 1)
for k in range(1, N + 1):
    S[k] = S[k - 1] + A[k - 1]
count = collections.Counter(S)
ans = 0
for k, v in list(count.items()):
    ans += v * (v - 1) // 2
print(ans)

def a_zero_sum_ranges(N, A):
    import collections
    import itertools

    # s[l]==s[r] のとき、A[l+1]+...+A[r] == 0 となる
    s = itertools.accumulate([0] + A)
    count = collections.Counter(s)
    ans = 0
    for k, v in list(count.items()):
        ans += v * (v - 1) // 2
    return ans


N = int(eval(input()))
A = [int(i) for i in input().split()]
print((a_zero_sum_ranges(N, A)))

-import collections +def a_zero_sum_ranges(N, A): +    import collections +    import itertools + +    # s[l]==s[r] のとき、A[l+1]+...+A[r] == 0 となる +    s = itertools.accumulate([0] + A) +    count = collections.Counter(s) +    ans = 0 +    for k, v in list(count.items()): +        ans += v * (v - 1) // 2 +    return ans + -S = [0] * (N + 1) -for k in range(1, N + 1): -    S[k] = S[k - 1] + A[k - 1] -count = collections.Counter(S) -ans = 0 -for k, v in list(count.items()): -    ans += v * (v - 1) // 2 -print(ans) +print((a_zero_sum_ranges(N, A)))