#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

ll gcd(ll a, ll b) { for (; b; a %= b, swap(a, b)); return a; }

const int N = 200001;
const ll MOD = 998244353;

ll n;
ll sum;
ll a[N];

ll solve(ll L, ll R, ll preSum)
{
	if (L > R) return 0;
	if (preSum * 2 >= sum) return 0;

	ll res = 0;

	ll lsum = preSum;
	ll r = L;
	while (r + 2 <= R && (lsum + a[r + 2]) * 2 < sum)
	{
		r += 2;
		lsum += a[r];
	}

	ll l = L;
	res += (r - l) / 2 + 1;
	res %= MOD;

	for (l += 2; l <= R; l += 2)
	{
		lsum += a[l - 1];
		while (lsum * 2 >= sum && l <= r)
		{
			lsum -= a[r];
			r -= 2;
		}

		if (l > r) break;
		res += (r - l) / 2 + 1;
		res %= MOD;
	}

	if (L + 1 <= R && (preSum + a[L + 1]) * 2 < sum)
	{
		preSum += a[L + 1];
		L++;

		ll lsum = preSum;
		ll r = L;
		while (r + 2 <= R && (lsum + a[r + 2]) * 2 < sum)
		{
			r += 2;
			lsum += a[r];
		}

		ll l = L;
		res += (r - l) / 2 + 1;
		res %= MOD;

		for (l += 2; l <= R; l += 2)
		{
			lsum += a[l - 1];
			while (lsum * 2 >= sum && l <= r)
			{
				lsum -= a[r];
				r -= 2;
			}

			if (l > r) break;
			res += (r - l) / 2 + 1;
			res %= MOD;
		}
	}

	return res;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

	int t; cin >> t;
	while (t--)
	{
		cin >> n;
		sum = 0;
		for (int i = 1; i <= n; i++)
		{
			cin >> a[i];
			sum += a[i];
		}

		ll ans = 0;

		ans += solve(0, n, 0);
		ans %= MOD;

		ans += solve(3, n, a[2] + a[3]);
		ans %= MOD;

		ans += solve(0, n - 3, a[n]);
		ans %= MOD;

		ans += solve(3, n - 3, a[2] + a[3] + a[n]);
		ans %= MOD;

		if (n >= 4)
		{
			ll tsum = a[n] + a[n - 1];
			for (int i = n - 2; i >= 2; i--)
			{
				if (tsum * 2 < sum)
					ans = (ans + 1) % MOD;

				tsum += a[i];
			}
		}

		//cout << "ANS : ";
		cout << ans << '\n';
	}
}