import math

N = int(input())
Ai = list(map(int,input().split()))
    
#print(Ai)
def create_list():
  MAXI = N
  
  sn = [0 for _ in range(MAXI+1)]
  judge = 0
  for i in range(1,MAXI+1):
    sn[i] = sn[i-1] + Ai[i-1]
     
  return sn

base = create_list()
#print(base)
count = 0
for i in range(N):
  for j in range(i+1,N+1):
    if(base[j]-base[i] == 0):
      count += 1
print(count)