object Main {
  def main(args: Array[String]): Unit = {
    readLine()
    val source = readLine().split(" ").toList.map(_.toInt)

    def zeroSum(lst: List[Int], count: Int = 0, res: Int = 0): Int = lst match {
      case Nil => count
      case int :: tail => zeroSum(
        tail,
        if (res + int == 0) count + 1 else count,
        res + int
      )
    }

    def zeroSumRanges(lst: List[Int], count: Int = 0): Int = lst match {
      case Nil => count
      case int :: tail => zeroSumRanges(tail, zeroSum(tail, count))
    }

    println(zeroSumRanges(0 :: source))

  }
  
}