#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll mod = 998244353;
constexpr int N = 200000 + 5;

ll n, a[N], s[N], ans, sum, now;

void calc(int p, int q) {
    if (now * 2 >= sum || p > q) return;
    // int L = 1, R = (q - p) / 2 + 1, res = 0;
    // while (L < R) {
    //     int mid = L + R >> 1;
    //     if ((now + s[p + mid * 2] - s[p]) >= sum) {
    //         R = mid;
    //     } else {
    //         res = mid;
    //         L = mid + 1;
    //     }
    // }
    // ans += res;
    // ans %= mod;
    int l = 1, r = (q - p)/2 + 1;
    
    while (l < r) {
        int mid = (l + r + 1)>>1;
        
        if ((now + s[p + (mid - 1)*2] - s[p])*2 >= sum) r = mid - 1;
        else l = mid;
    }
    
    ans += l;
}

void solve() {
    ans = sum = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum += a[i];
        s[i] = a[i];
        if (i > 2) s[i] += s[i - 2];
    }
    /*
        P...PC...C
        P...P
    */
    for (int i = 1; i <= n; i++) ans += 2 * (s[i] + s[i - 1]) > sum;
    for (int i = 1; i <= n; i++) {
        now = s[i - 1] + s[i];
        calc(i, n - 1);
        now += a[n];
        calc(i, n - 2);
        if (i > 1) {
            now -= a[1];
            calc(i, n - 2);
            now -= a[n];
            calc(i, n - 1);
        }
    }
    cout << ans % mod << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(20);
    int T;
    cin >> T;
    while (T--) solve();
    return 0;
}