output_description: Find the number of the non-empty contiguous subsequences of A whose sum is 0.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      A_1 A_2 ... A_N
attempt: import sys
  
  input = sys.stdin.readline
  
  # import numpy as np
  import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
  from collections import deque, defaultdict, Counter
  
  # from heapq import heappush, heappop
  from itertools import permutations, combinations, product, accumulate, groupby
  from bisect import bisect_left, bisect_right, insort_left, insort_right
  
  # from operator import itemgetter as ig
  
  # sys.setrecursionlimit(10 ** 7)
  # nf = 10 ** 20
  # INF = float("INF")
  # mod = 10 ** 9 + 7
  
  """
  dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
  ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
  ddn9 = ddn + [(0, 0)]
  for dx, dy in dd:
          nx = j + dx; ny = i + dy
              if 0 <= nx < w and 0 <= ny < h:
  
  def wi(): return list(map(int, sys.stdin.readline().split()))
  def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]  # WideIntPoint
  def ws(): return sys.stdin.readline().split()
  def si(): return int(sys.stdin.readline())  # SingleInt
  def ss(): return input()
  def hi(n): return [si() for _ in range(n)]
  def hs(n): return [ss() for _ in range(n)]  # HeightString
  def s_list(): return list(input())
  def mi(n): return [wi() for _ in range(n)]  # MatrixInt
  def mip(n): return [wip() for _ in range(n)]
  def ms(n): return [ws() for _ in range(n)]
  def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]  # NumberGrid
  def grid(n): return [s_list() for _ in range(n)]
  # 深さ優先探索
  def dfs(G, v):
      global time, first_order,seen,last_order
      time += 1
      first_order[v-1] = time   #　行きがけ
  
      seen[v-1] = True # v を訪問済みにする
      # v から行ける各頂点 next_v について
      for next_v in G[v]:
          if seen[next_v-1]:
              continue
          dfs(G, next_v)
  
      time += 1
      last_order[v - 1] = time  # 帰りがけ
  """
  
  
  def main():
  
      a = [0] + list(map(int, input().split()))
      a = list(accumulate(a))
      c = Counter(a)
      ans = 0
      for i in c.values():
          ans += i * (i - 1) // 2
      print(ans)
  
  
  if __name__ == "__main__":
      main()
  
problem_description: Statement
  
  We have an integer sequence A, whose length is N.
  
  Find the number of the non-empty **contiguous** subsequences of A whose sums
  are 0. Note that we are counting **the ways to take out subsequences**. That
  is, even if the contents of some two subsequences are the same, they are
  counted individually if they are taken from different positions.
samples: [{"input": "6\n    1 3 -4 2 2 -2", "output": "3\n    \n\nThere are three contiguous subsequences whose sums are 0: (1,3,-4), (-4,2,2)\nand (2,-2).\n\n* * *"}, {"input": "7\n    1 -1 1 -1 1 -1 1", "output": "12\n    \n\nIn this case, some subsequences that have the same contents but are taken from\ndifferent positions are counted individually. For example, three occurrences\nof (1, -1) are counted.\n\n* * *"}, {"input": "5\n    1 -2 3 -4 5", "output": "0\n    \n\nThere are no contiguous subsequences whose sums are 0."}]