from itertools import accumulate 
from math import factorial
def cmb(n,r):
    return factorial(n) // (factorial(n - r) * factorial(r))

def resolve():
    n = int(input())
    li =list(map(int, input().split()))

    li2 = list(accumulate(li))

    sun = [0]
    sun = sun + li2

    stsm = sorted(sun)
    stsm.append(0)

    ans = 0
    sli = []
    memo = 0
    for i in range(n + 1):
        if stsm[i] != stsm[i + 1]:
           sli.append(stsm[memo : i + 1]) 
           memo = i + 1
    
    for i in sli:
        a = len(i)
        if a < 2:
            continue
        else:
            ans += cmb(a,2)

    print(ans)
resolve()