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 = 'def abc(l,val):\n i=0\n j=len(l)-1\n s=-1\n while i<=j:\n  mid = i+(j-i)//2\n  if l[mid]<val:\n   s=mid\n   i=mid+1\n  else:\n   j=mid-1\n return s+1\ndef bca(l,val):\n i=0\n j=len(l)-1\n s=len(l)\n while i<=j:\n  mid = i+(j-i)//2\n  if l[mid]>=val:\n   s=mid\n   j=mid-1\n  else:\n   i=mid+1\n m=0\n return len(l)-s\n \nimport random\nt=int(input())\nfor _ in range(t):\n n=int(input())\n l=list(map(int,input().split()))\n x=sum(l)\n ans=0\n k=[l[0]]\n for i in range(1,n):\n  k.append(k[-1]+l[i])\n d={}\n for i in range(n):\n  try:\n   d[k[i]]+=[i]\n  except:\n   d[k[i]]=[i]\n for i in range(n):\n  s =x-l[i]\n  if not s%2:\n   try:\n    c = d[s//2]\n    ans+=abc(c,i)\n   except:\n    pass\n   try:\n    c=d[s//2+l[i]]\n    ans+=bca(c,i)\n    if k[-1]==s//2+l[i]:\n     ans-=1\n   except:\n    pass\n   \n print(ans)\n   \n     \n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13827