You are given a sequence $A_1, A_2, \ldots, A_N$. For each $k$ ($1 \le k \le N$), let's define a function $f(k)$ in the following way:
- Consider a sequence $B_1, B_2, \ldots, B_N$, which is created by setting $A_k = 0$. Formally, $B_k = 0$ and $B_i = A_i$ for each valid $i \neq k$.
- $f(k)$ is the number of ways to split the sequence $B$ into two non-empty contiguous subsequences with equal sums.
Find the sum $S = f(1) + f(2) + \ldots + f(N)$.

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first line of each test case contains a single integer $N$.
- The second line contains $N$ space-separated integers $A_1, A_2, \ldots, A_N$.

-----Output-----
For each test case, print a single line containing one integer — the sum $S$.

-----Constraints-----
- $1 \le T \le 10$
- $2 \le N \le 2 \cdot 10^5$
- $1 \le |A_i| \le 10^9$ for each valid $i$

-----Example Input-----
2
6
1 2 1 1 3 1
3
4 1 4

-----Example Output-----
6
2

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = '# @Author: Atul Sahay <atul>\n# @Date:   2020-01-20T11:31:52+05:30\n# @Email:  atulsahay01@gmail.com, atulsahay@cse.iitb.ac.in\n# @Last modified by:   atul\n# @Last modified time: 2020-01-20T23:18:12+05:30\n# from operator import sub\n#\n# def Diff(li1, li2):\n#     # print(li1)\n#     # print(li2)\n#     return  list(map(int.__sub__, li1,li2))\n#\n# def binary_search(l,val,start,end):\n#     # print("start",start,"end",end)\n#     # print("l",l)\n#     if(start>end):\n#         return 0\n#     mid = (start + end) //2\n#     # print("mid",mid)\n#     if(l[mid] == val):\n#         return (1+binary_search(l,val,start,mid-1)+binary_search(l,val,mid+1\xa0\xa0\xa0\xa0,end))\n#     elif(l[mid]>val):\n#         return (binary_search(l,val,start,mid-1))\n#     else:\n#         return(binary_search(l,val,mid+1,end))\n#\n# for t in range(int(input())):\n#     n = int(input())\n#     a = list(map(int,input().strip().split()))\n#     total = sum(a)\n#     inter_sum = 0\n#     S = 0\n#     b = []\n#     for i in a:\n#         inter_sum+=i\n#         b.append(inter_sum)\n#     # print(b)\n#     for i in range(n):\n#         inter_sum = total - a[i]\n#         if(inter_sum%2!=0):\n#             continue\n#         c_l = [0]*i\n#         c_r = [a[i]]*(n-i)\n#         c_l.extend(c_r)\n#         # print(c_l)\n#         l = Diff(b,c_l)\n#         # print(l)\n#         S+=binary_search(l,inter_sum//2,0,n-1)\n#     print(S)\n\nimport bisect\n\nfor t in range(int(input())):\n n = int(input())\n a = list(map(int,input().strip().split()))\n total = sum(a)\n diff = {}\n inter_sum = 0\n for i in range(n-1):\n  if(a[i]==0):\n   continue\n  inter_sum+=a[i]\n  c = inter_sum-(total-inter_sum)\n  if(c in list(diff.keys())):\n   diff[c].append(i)\n  else:\n   diff[c] = [i]\n count = 0\n # print(diff)\n for i in range(n):\n  # print("i",i)\n  if(-a[i] in list(diff.keys())):\n   ans = bisect.bisect_left(diff[-a[i]],i)\n\n   count+=ans\n   # print(1,ans)\n  if(a[i] in list(diff.keys())):\n   ans = bisect.bisect_left(diff[a[i]],i)\n   count+=(len(diff[a[i]])-ans)\n   # print(2,ans)\n print(count)\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13629