let N = Int(readLine()!)!
let A = readLine()!.characters.split(" ").map{Int(String($0))!}
var S = [0]
for i in 0..<N {
  S += [S[i]+A[i]]
}
var s = [Int: Int]()
for i in S {
  s[i] = (s[i] ?? 0) + 1
}
print(s.values.reduce(0){$0+$1*($1-1)/2})