import sys
from collections import Counter
import random
import time
import math

def comb(n, r):
    return (math.factorial(n)//(math.factorial(n-r)*math.factorial(r)))

n=int(input())
a=list(map(int,input().split()))
S=[sum(a[:i])for i in range(n+1)]
s=set(S)
c=0
for i in s:
    nu=S.count(i)
    if(nu>1):c+=comb(nu,2)
print(c)