import sequtils, strutils, unicode

proc subRange(whole: seq[int], first: int, last: int): seq[int] =
  result = whole
  result = result[first..last] 

proc solve(nums: seq[int]): int =
  result = 0
  for first in 0..<nums.len-1:
    for last in first+1..<nums.len:
      let target = nums.subRange(first, last)
      var sum = 0
      for n in target:
        sum += n
      if sum == 0:
        inc result

proc main() =
  let _ = stdin.readLine()
  let nums = stdin.readLine().split().map(parseInt)
  echo $solve(nums)

main()