#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define fi first
#define se second
const int MAX_N = 2e5 + 10;
int N, a[MAX_N];
LL s1[MAX_N], s2[MAX_N];
int calc(int L, int R, LL cur) {
    int l = 0, r, res = 0;
    if (L & 1) r = (R + 1) / 2 - (L + 1) / 2;
    else r = R / 2 - L / 2;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (2 * (cur + s2[L + 2 * mid] - s2[L]) < s1[N]) res = mid, l = mid + 1;
        else r = mid - 1;
    }
    return res;
}
void solve() {
    scanf("%d", &N);
    for (int i = 1; i <= N; i++) scanf("%d", a + i);
    for (int i = 1; i <= N; i++) s1[i] = s1[i - 1] + a[i];
    s2[1] = a[1];
    for (int i = 2; i <= N; i++) s2[i] = s2[i - 2] + a[i];
    LL ans = 0;
    for (int i = 1; i <= 2; i++)
        for (int j = i; j <= N; j++) {
            if (2 * (s1[j] - s1[i - 1]) < s1[N]) {
                ans += calc(j, N - 1, s1[j] - s1[i - 1]) + 1;
            }
            if (2 * (s1[j] - s1[i - 1] + a[N]) < s1[N] && j <= N - 2) {
                ans += calc(j, N - 2, s1[j] - s1[i - 1] + a[N]) + 1;
            }
        }
    for (int i = 3; i <= N; i++) ans += s1[N] - s1[i - 1] < s1[i - 1];
    ans++;
    printf("%lld\n", ans % 998244353);
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("cpp.in", "r", stdin);
#endif
    int T; scanf("%d", &T);
    while (T--) solve();
    return 0;
}