n=int(eval(input()))

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

import math

s=[0]*(n+1)#累積和法

a.insert(0,0)

for i in range(1,n+1):

    s[i]=s[i-1]+a[i]

from collections import Counter

data=Counter(s)

def combination_cout(n,r):

    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))#組み合わせ計算

ans=[]

for i in list(data.values()):

    if 2<=i:#同じ文字が2個以上ある時の文字数

        ans.append(i)

total=0

for i in ans:

    total+=combination_cout(i,2)

print(total)

        

n=int(eval(input()))

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

from collections import Counter

a.insert(0,0)

s=[0]*(n+1)

for i in range(1,n+1):

    s[i]=s[i-1]+a[i]

data=Counter(s)

cnt=[]

for i in list(data.values()):

    if 2<=i:

        cnt.append(i)

def combination_cnt(n):

    return n*(n-1)//2

ans=0

for i in range(len(cnt)):

    ans+=combination_cnt(cnt[i])

print(ans)





n = int(eval(input()))
a = list(map(int, input().split()))
import math

s = [0] * (n + 1)  # 累積和法
a.insert(0, 0)
for i in range(1, n + 1):
    s[i] = s[i - 1] + a[i]
from collections import Counter

data = Counter(s)


def combination_cout(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))  # 組み合わせ計算


ans = []
for i in list(data.values()):
    if 2 <= i:  # 同じ文字が2個以上ある時の文字数
        ans.append(i)
total = 0
for i in ans:
    total += combination_cout(i, 2)
print(total)

n = int(eval(input()))
a = list(map(int, input().split()))
from collections import Counter

a.insert(0, 0)
s = [0] * (n + 1)
for i in range(1, n + 1):
    s[i] = s[i - 1] + a[i]
data = Counter(s)
cnt = []
for i in list(data.values()):
    if 2 <= i:
        cnt.append(i)


def combination_cnt(n):
    return n * (n - 1) // 2


ans = 0
for i in range(len(cnt)):
    ans += combination_cnt(cnt[i])
print(ans)

-import math +from collections import Counter -s = [0] * (n + 1)  # 累積和法 +s = [0] * (n + 1) -from collections import Counter - +cnt = [] +for i in list(data.values()): +    if 2 <= i: +        cnt.append(i) -def combination_cout(n, r): -    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))  # 組み合わせ計算 +def combination_cnt(n): +    return n * (n - 1) // 2 -ans = [] -for i in list(data.values()): -    if 2 <= i:  # 同じ文字が2個以上ある時の文字数 -        ans.append(i) -total = 0 -for i in ans: -    total += combination_cout(i, 2) -print(total) +ans = 0 +for i in range(len(cnt)): +    ans += combination_cnt(cnt[i]) +print(ans)