# coding:utf-8



import sys

from collections import Counter





input = sys.stdin.readline

INF = float('inf')





def inpl(): return list(map(int, input().split()))





N = int(eval(input()))

A = inpl()



S = [0]

for i in range(N):

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



cnt_num = Counter(S)

ans = 0

for num in list(cnt_num.keys()):

    cnt = cnt_num[num]

    if cnt < 2:

        continue

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



print(ans)

# coding:utf-8



import sys

from collections import Counter, defaultdict



INF = float('inf')

MOD = 10 ** 9 + 7



def LI(): return [int(x) for x in sys.stdin.readline().split()]

def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]

def LS(): return sys.stdin.readline().split()

def II(): return int(sys.stdin.readline())

def SI(): return eval(input())





def main():

    n = II()

    A = LI()



    B = [0]

    for a in A:

        B.append(B[-1] + a)

    C = Counter(B)



    res = 0

    for c in list(C.values()):

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



    return res





print((main()))

# coding:utf-8
import sys
from collections import Counter

input = sys.stdin.readline
INF = float("inf")


def inpl():
    return list(map(int, input().split()))


N = int(eval(input()))
A = inpl()
S = [0]
for i in range(N):
    S.append(S[-1] + A[i])
cnt_num = Counter(S)
ans = 0
for num in list(cnt_num.keys()):
    cnt = cnt_num[num]
    if cnt < 2:
        continue
    ans += cnt * (cnt - 1) // 2
print(ans)

# coding:utf-8
import sys
from collections import Counter, defaultdict

INF = float("inf")
MOD = 10**9 + 7


def LI():
    return [int(x) for x in sys.stdin.readline().split()]


def LI_():
    return [int(x) - 1 for x in sys.stdin.readline().split()]


def LS():
    return sys.stdin.readline().split()


def II():
    return int(sys.stdin.readline())


def SI():
    return eval(input())


def main():
    n = II()
    A = LI()
    B = [0]
    for a in A:
        B.append(B[-1] + a)
    C = Counter(B)
    res = 0
    for c in list(C.values()):
        res += c * (c - 1) // 2
    return res


print((main()))

-from collections import Counter +from collections import Counter, defaultdict -input = sys.stdin.readline +MOD = 10**9 + 7 -def inpl(): -    return list(map(int, input().split())) +def LI(): +    return [int(x) for x in sys.stdin.readline().split()] -N = int(eval(input())) -A = inpl() -S = [0] -for i in range(N): -    S.append(S[-1] + A[i]) -cnt_num = Counter(S) -ans = 0 -for num in list(cnt_num.keys()): -    cnt = cnt_num[num] -    if cnt < 2: -        continue -    ans += cnt * (cnt - 1) // 2 -print(ans) +def LI_(): +    return [int(x) - 1 for x in sys.stdin.readline().split()] + + +def LS(): +    return sys.stdin.readline().split() + + +def II(): +    return int(sys.stdin.readline()) + + +def SI(): +    return eval(input()) + + +def main(): +    n = II() +    A = LI() +    B = [0] +    for a in A: +        B.append(B[-1] + a) +    C = Counter(B) +    res = 0 +    for c in list(C.values()): +        res += c * (c - 1) // 2 +    return res + + +print((main()))