import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy



sys.setrecursionlimit(10**7)

inf=10**20

mod=10**9+7

dd=[(-1,0),(0,1),(1,0),(0,-1)]

ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]



def LI(): return [int(x) for x in sys.stdin.readline().split()]

def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]

def I(): return int(sys.stdin.readline())

def LS(): return sys.stdin.readline().split()

def S(): return eval(input())



# Summarize count of factor within list -- START --

def summarize_list(l):

  sl=sorted(l)



  a=sl[0]

  c=1

  res=[]



  for x in sl[1:]:

    if x==a:

      c+=1

    else:

      res.append([a,c])

      a=x

      c=1

  res.append([a,c])



  return res

# Summarize count of factor within list --- END ---



# nCr -- START --

def nCr(n,r):

  if n<r:

    return 0

  return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

# nCr --- END ---



def main():

  n=I()

  l=LI()



  for i in range(n-1):

    l[i+1]+=l[i]



  l=summarize_list(l)



  ans=0

  for x in l:

    if x[0]==0:

      ans+=x[1]



    if x[1]>1:

      ans+=nCr(x[1],2)



  return ans



# main()

print((main()))

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy



sys.setrecursionlimit(10**7)

inf=10**20

mod=10**9+7

dd=[(-1,0),(0,1),(1,0),(0,-1)]

ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]



def LI(): return [int(x) for x in sys.stdin.readline().split()]

def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]

def I(): return int(sys.stdin.readline())

def LS(): return sys.stdin.readline().split()

def S(): return eval(input())



# Summarize count of factor within list -- START --

def summarize_list(l):

  sl=sorted(l)



  a=sl[0]

  c=1

  res=[]



  for x in sl[1:]:

    if x==a:

      c+=1

    else:

      res.append([a,c])

      a=x

      c=1

  res.append([a,c])



  return res

# Summarize count of factor within list --- END ---



def main():

  n=I()

  l=LI()



  for i in range(n-1):

    l[i+1]+=l[i]



  l=summarize_list(l)



  ans=0

  for a,b in l:

    if a==0:

      ans+=b

      if b>1:

        ans+=b*(b-1)//2

    else:

      if b>1:

        ans+=b*(b-1)//2



  return ans



# main()

print((main()))

import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI():
    return [int(x) for x in sys.stdin.readline().split()]


def LI_():
    return [int(x) - 1 for x in sys.stdin.readline().split()]


def I():
    return int(sys.stdin.readline())


def LS():
    return sys.stdin.readline().split()


def S():
    return eval(input())


# Summarize count of factor within list -- START --
def summarize_list(l):
    sl = sorted(l)
    a = sl[0]
    c = 1
    res = []
    for x in sl[1:]:
        if x == a:
            c += 1
        else:
            res.append([a, c])
            a = x
            c = 1
    res.append([a, c])
    return res


# Summarize count of factor within list --- END ---
# nCr -- START --
def nCr(n, r):
    if n < r:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


# nCr --- END ---
def main():
    n = I()
    l = LI()
    for i in range(n - 1):
        l[i + 1] += l[i]
    l = summarize_list(l)
    ans = 0
    for x in l:
        if x[0] == 0:
            ans += x[1]
        if x[1] > 1:
            ans += nCr(x[1], 2)
    return ans


# main()
print((main()))

import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI():
    return [int(x) for x in sys.stdin.readline().split()]


def LI_():
    return [int(x) - 1 for x in sys.stdin.readline().split()]


def I():
    return int(sys.stdin.readline())


def LS():
    return sys.stdin.readline().split()


def S():
    return eval(input())


# Summarize count of factor within list -- START --
def summarize_list(l):
    sl = sorted(l)
    a = sl[0]
    c = 1
    res = []
    for x in sl[1:]:
        if x == a:
            c += 1
        else:
            res.append([a, c])
            a = x
            c = 1
    res.append([a, c])
    return res


# Summarize count of factor within list --- END ---
def main():
    n = I()
    l = LI()
    for i in range(n - 1):
        l[i + 1] += l[i]
    l = summarize_list(l)
    ans = 0
    for a, b in l:
        if a == 0:
            ans += b
            if b > 1:
                ans += b * (b - 1) // 2
        else:
            if b > 1:
                ans += b * (b - 1) // 2
    return ans


# main()
print((main()))

-# nCr -- START -- -def nCr(n, r): -    if n < r: -        return 0 -    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) - - -    for x in l: -        if x[0] == 0: -            ans += x[1] -        if x[1] > 1: -            ans += nCr(x[1], 2) +    for a, b in l: +        if a == 0: +            ans += b +            if b > 1: +                ans += b * (b - 1) // 2 +        else: +            if b > 1: +                ans += b * (b - 1) // 2