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
  import os
  if sys.platform=="darwin":
  	base = os.path.dirname(os.path.abspath(__file__))
  	name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
  	#print(name)
  	sys.stdin = open(name)
  
  #nCrの計算。nこの中から、r個を取り出す。
  import import sys
  import os
  if sys.platform=="darwin":
  	base = os.path.dirname(os.path.abspath(__file__))
  	name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
  	#print(name)
  	sys.stdin = open(name)
  
  #読み込みの高速化
  input = sys.stdin.readline
  
  #nCrの計算。nこの中から、r個を取り出す。
  import math
  def combinations_count(n, r):
      return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
  
  import copy
  
  
  n = int(input())
  a = list(map(int,input().split()))
  
  b = [0]*(n+1)
  b[0] = 0
  for i in range(1,n+1):
  	b[i] = b[i-1] + a[i-1]
  
  #print(b)
  
  c = [0]*(n+1)
  c = copy.copy(b)
  c = list(set(c))
  #print(c)
  
  ans = 0
  
  for i in c:
  	#print(i)
  	chk = b.count(i)
  	#print(chk)
  	if chk >= 2:
  		ans = ans + combinations_count(chk,2)
  
  print(ans)
  
  
  
  def combinations_count(n, r):
      return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
  
  import copy
  
  
  n = int(input())
  a = list(map(int,input().split()))
  
  b = [0]*(n+1)
  b[0] = 0
  for i in range(1,n+1):
  	b[i] = b[i-1] + a[i-1]
  
  #print(b)
  
  c = [0]*(n+1)
  c = copy.copy(b)
  c = list(set(c))
  #print(c)
  
  ans = 0
  
  for i in c:
  	#print(i)
  	chk = b.count(i)
  	#print(chk)
  	if chk >= 2:
  		ans = ans + combinations_count(chk,2)
  
  print(ans)
  
  
  
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."}]