import sequtils, strutils, algorithm, math, sets, tables
when NimMajor == 0 and NimMinor <= 18: import future else: import sugar
#template SEQ2D(y,x:int,p:untyped):untyped=newSeqWith(y,newSeqWith(x,p))

var N = stdin.readline.parseInt
var A = stdin.readline.split.map(parseInt)

var wa = newSeqWith(N+1,0)
for i in 0..<N:
  wa[i+1] = wa[i] + A[i]

var ans = 0
for j in 0..<N-1:
  for i in (j+1)..<N:
    if wa[i+1]-wa[j] == 0:
      ans += 1

echo ans