from collections import Counter



n = int(eval(input()))

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



a_ = [0]



for i in range(n):

    a_.append(a_[i] + a[i])



cnt = 0



def sum(i):

    return int((i + 1) / 2 * i)



for i in list(Counter(a_).values()):

    cnt += sum(i-1)



print(cnt)
from collections import Counter



n = int(eval(input()))

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



a_ = [0]



for i in range(n):

    a_.append(a_[i] + a[i])



cnt = 0



def sum(i):

    return i * (i-1) // 2



for i in list(Counter(a_).values()):

    cnt += sum(i)



print(cnt)
from collections import Counter

n = int(eval(input()))
a = [int(i) for i in input().split()]
a_ = [0]
for i in range(n):
    a_.append(a_[i] + a[i])
cnt = 0


def sum(i):
    return int((i + 1) / 2 * i)


for i in list(Counter(a_).values()):
    cnt += sum(i - 1)
print(cnt)

from collections import Counter

n = int(eval(input()))
a = [int(i) for i in input().split()]
a_ = [0]
for i in range(n):
    a_.append(a_[i] + a[i])
cnt = 0


def sum(i):
    return i * (i - 1) // 2


for i in list(Counter(a_).values()):
    cnt += sum(i)
print(cnt)

-    return int((i + 1) / 2 * i) +    return i * (i - 1) // 2 -    cnt += sum(i - 1) +    cnt += sum(i)