import sys

readline = sys.stdin.buffer.readline

from collections import Counter



n = int(readline())

lst1 = list(map(int,readline().split()))



def cumsum(lst): #元のリストを保持

    res = lst[:]

    for i in range(1,len(res)):

        res[i] += res[i-1]

    return res

lst2 = [0]+cumsum(lst1)



c = Counter(lst2)



ans = 0

for i in range(len(lst2)-1):

    c[lst2[i]] -= 1

    ans += c[lst2[i]]



print(ans)
import sys

readline = sys.stdin.buffer.readline



n = int(readline())

lst1 = list(map(int,readline().split()))



def cumsum(lst): #元のリストを保持

    res = lst[:]

    for i in range(1,len(res)):

        res[i] += res[i-1]

    return res

lst2 = [0] + cumsum(lst1)



ans = 0



dic1 = dict()

for i in lst2:

    if i in dic1:

        ans += dic1[i]

        dic1[i] += 1

    else:

        dic1[i] = 1



print(ans)
import sys

readline = sys.stdin.buffer.readline
from collections import Counter

n = int(readline())
lst1 = list(map(int, readline().split()))


def cumsum(lst):  # 元のリストを保持
    res = lst[:]
    for i in range(1, len(res)):
        res[i] += res[i - 1]
    return res


lst2 = [0] + cumsum(lst1)
c = Counter(lst2)
ans = 0
for i in range(len(lst2) - 1):
    c[lst2[i]] -= 1
    ans += c[lst2[i]]
print(ans)

import sys

readline = sys.stdin.buffer.readline
n = int(readline())
lst1 = list(map(int, readline().split()))


def cumsum(lst):  # 元のリストを保持
    res = lst[:]
    for i in range(1, len(res)):
        res[i] += res[i - 1]
    return res


lst2 = [0] + cumsum(lst1)
ans = 0
dic1 = dict()
for i in lst2:
    if i in dic1:
        ans += dic1[i]
        dic1[i] += 1
    else:
        dic1[i] = 1
print(ans)

-from collections import Counter - -c = Counter(lst2) -for i in range(len(lst2) - 1): -    c[lst2[i]] -= 1 -    ans += c[lst2[i]] +dic1 = dict() +for i in lst2: +    if i in dic1: +        ans += dic1[i] +        dic1[i] += 1 +    else: +        dic1[i] = 1