n=int(eval(input()))

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

acum=[0]*(n+1)

cnt=0

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

  acum[i]=acum[i-1]+arr[i-1]

acum=sorted(acum)

acum.append(10**10)

tmp=1

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

  if  acum[i]==acum[i-1]:

    tmp+=1

  else:

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

    tmp=1

print(cnt)
import collections



n=int(eval(input()))

arr=[0]+list(map(int,input().split()))

for i in range(n):

  arr[i+1]+=arr[i]

cnt=collections.Counter(arr)

ans=0

for val in list(cnt.values()):

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

print(ans)
n = int(eval(input()))
arr = list(map(int, input().split()))
acum = [0] * (n + 1)
cnt = 0
for i in range(1, n + 1):
    acum[i] = acum[i - 1] + arr[i - 1]
acum = sorted(acum)
acum.append(10**10)
tmp = 1
for i in range(1, len(acum)):
    if acum[i] == acum[i - 1]:
        tmp += 1
    else:
        cnt += tmp * (tmp - 1) // 2
        tmp = 1
print(cnt)

import collections

n = int(eval(input()))
arr = [0] + list(map(int, input().split()))
for i in range(n):
    arr[i + 1] += arr[i]
cnt = collections.Counter(arr)
ans = 0
for val in list(cnt.values()):
    ans += val * (val - 1) // 2
print(ans)

+import collections + -arr = list(map(int, input().split())) -acum = [0] * (n + 1) -cnt = 0 -for i in range(1, n + 1): -    acum[i] = acum[i - 1] + arr[i - 1] -acum = sorted(acum) -acum.append(10**10) -tmp = 1 -for i in range(1, len(acum)): -    if acum[i] == acum[i - 1]: -        tmp += 1 -    else: -        cnt += tmp * (tmp - 1) // 2 -        tmp = 1 -print(cnt) +arr = [0] + list(map(int, input().split())) +for i in range(n): +    arr[i + 1] += arr[i] +cnt = collections.Counter(arr) +ans = 0 +for val in list(cnt.values()): +    ans += val * (val - 1) // 2 +print(ans)