program test
implicit none
integer(8) :: n,a(200000),ruiseki(200000)=0,x=0,i,j
read(*,*) n

  read(*,*) (a(i),i=1,n)

ruiseki(1) = a(1)
 
do i=2,n
  ruiseki(i) = ruiseki(i-1) + a(i)
enddo

do i=2,n
  if(ruiseki(i) == 0) then
  x = x+1
  endif
enddo

do i=1,n
  do j=i+1,n
    if(ruiseki(i) == ruiseki(j)) then
      x  = x + 1
    endif
  enddo
enddo

write(*,*) x

end program