← Home
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

const MOD = 998244353

var fact, invFact []int64

func power(base, exp int64) int64 {
	res := int64(1)
	base %= MOD
	for exp > 0 {
		if exp%2 == 1 {
			res = (res * base) % MOD
		}
		base = (base * base) % MOD
		exp /= 2
	}
	return res
}

func modInverse(n int64) int64 {
	return power(n, MOD-2)
}

func precompute(maxN int) {
	fact = make([]int64, maxN+1)
	invFact = make([]int64, maxN+1)
	fact[0] = 1
	invFact[0] = 1
	for i := 1; i <= maxN; i++ {
		fact[i] = (fact[i-1] * int64(i)) % MOD
	}
	invFact[maxN] = modInverse(fact[maxN])
	for i := maxN - 1; i >= 1; i-- {
		invFact[i] = (invFact[i+1] * int64(i+1)) % MOD
	}
}

func nCr(n, r int) int64 {
	if r < 0 || r > n {
		return 0
	}
	return fact[n] * invFact[r] % MOD * invFact[n-r] % MOD
}

func findRange(S []int64, V int64, n int) (int, int) {
	L := sort.Search(n-1, func(k int) bool {
		return S[k+2] <= V
	}) + 2
	if L > n || S[L] != V {
		return -1, -1
	}
	R := sort.Search(n-1, func(k int) bool {
		return S[k+2] < V
	}) + 1
	return L, R
}

func main() {
	precompute(200005)

	scanner := bufio.NewScanner(os.Stdin)
	const maxCapacity = 10 * 1024 * 1024
	buf := make([]byte, maxCapacity)
	scanner.Buffer(buf, maxCapacity)
	scanner.Split(bufio.ScanWords)

	readInt := func() int {
		scanner.Scan()
		res := 0
		for _, b := range scanner.Bytes() {
			res = res*10 + int(b-'0')
		}
		return res
	}

	if !scanner.Scan() {
		return
	}
	t := 0
	for _, b := range scanner.Bytes() {
		t = t*10 + int(b-'0')
	}

	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	for tc := 0; tc < t; tc++ {
		n := readInt()
		a := make([]int64, n+1)
		for i := 1; i <= n; i++ {
			a[i] = int64(readInt())
		}

		if n == 1 {
			fmt.Fprintln(out, 1)
			continue
		}

		P := make([]int64, n+1)
		for i := 1; i <= n; i++ {
			P[i] = P[i-1] + a[i]
		}

		S := make([]int64, n+2)
		for i := n; i >= 1; i-- {
			S[i] = S[i+1] + a[i]
		}

		ans := int64(1)
		i := 1
		for i <= n-1 {
			V := P[i]
			if 2*V > P[n] {
				break
			}
			j := i
			for j+1 <= n-1 && P[j+1] == V {
				j++
			}

			L, R := findRange(S, V, n)
			if L != -1 {
				sumWays := int64(0)
				for x := i; x <= j; x++ {
					c := x - i
					d := 0
					firstY := x + 1
					if firstY < L {
						firstY = L
					}
					if firstY <= R {
						d = R - firstY + 1
					}
					ways := nCr(c+d, c+1)
					sumWays = (sumWays + ways) % MOD
				}
				ans = (ans * (1 + sumWays)) % MOD
			}

			i = j + 1
		}

		fmt.Fprintln(out, ans)
	}
}