import sys

from collections import Counter



sys.setrecursionlimit(10 ** 7)

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

    n = int(eval(input()))

    A = list(map(int, input().split()))



    R = [0]

    for i in range(n):

        R.append(R[-1] + A[i])



    D = Counter(R)

    res = 0

    for v in list(D.values()):

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



    print(res)





if __name__ == '__main__':

    resolve()

import sys

from itertools import accumulate

from collections import Counter



sys.setrecursionlimit(10 ** 7)

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

    n = int(eval(input()))

    A = list(map(int, input().split()))



    R = [0] + list(accumulate(A))

    D = Counter(R)



    res = 0

    for v in list(D.values()):

        if v >= 2:

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

    print(res)





if __name__ == '__main__':

    resolve()

import sys
from collections import Counter

sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    n = int(eval(input()))
    A = list(map(int, input().split()))
    R = [0]
    for i in range(n):
        R.append(R[-1] + A[i])
    D = Counter(R)
    res = 0
    for v in list(D.values()):
        res += v * (v - 1) // 2
    print(res)


if __name__ == "__main__":
    resolve()

import sys
from itertools import accumulate
from collections import Counter

sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    n = int(eval(input()))
    A = list(map(int, input().split()))
    R = [0] + list(accumulate(A))
    D = Counter(R)
    res = 0
    for v in list(D.values()):
        if v >= 2:
            res += v * (v - 1) // 2
    print(res)


if __name__ == "__main__":
    resolve()

+from itertools import accumulate -    R = [0] -    for i in range(n): -        R.append(R[-1] + A[i]) +    R = [0] + list(accumulate(A)) -        res += v * (v - 1) // 2 +        if v >= 2: +            res += v * (v - 1) // 2