#解説見た
#--------------------------------------------------
import strutils, sequtils, math, algorithm, tables, sets, lists, intsets, critbits, future
let read* = iterator: string {.closure.} =
    while true: (for s in stdin.readLine.split: yield s)
proc scan(): int = read().parseInt
const MOD = 10^9+7

proc pow(a:int,n:int,mo:int = int.high): int =
    result = 1
    var a = a
    var n = n
    while n>0:
        if (n and 1)==1: result = result * a mod mo
        a = a * a mod mo
        n = n shr 1
proc comb(n:int, r:int, mo:int): int =
    var upe:int = 1;
    var dow:int = 1;
    var n = n
    for i in 1..r:
        upe = upe * n mod mo;
        dow = dow * i mod mo;
        n -= 1;
    return upe * pow(dow, mo-2, mo) mod mo
#--------------------------------------------------
var n = scan()
var a = newSeqWith(n, scan())

var s = newSeq[int](n+1)
for i in 1..n:
    s[i] = s[i-1] + a[i-1]

s.sort(cmp)
s.add(int.low)
var ans = 0
var prev = int.high
var cnt = 1
for i in s:
    if i == prev: cnt += 1
    else:
        ans += comb(cnt, 2, MOD)
        cnt = 1
    prev = i

echo ans