#include <bits/stdc++.h>
#define sz(x) int(x.size())
#define uni(x) x.resize(unique(x.begin(), x.end()) - x.begin())
#define ms(x, n) memset(x, n, sizeof(x))
#define mc(a, b) memcpy(a, b, sizeof(b))
#define tomax(a, b) a = max(a, b)
#define tomin(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int inf = 0x3f3f3f3f;
const int ninf = 0xc0c0c0c0;
const ll linf = 0x3f3f3f3f3f3f3f3fll;
const ll lninf = 0xc0c0c0c0c0c0c0c0ll;

const int mo = 998244353;

int a[200005];
ll sum[200005], sum2[200005];

ll solve(int lb, int rb, int ac, int ap) {
    ll ans = 0;
    for (int i = lb; i <= rb; i++) {
        int l = i - 1, r = rb;
        while (l < r) {
            int mid = (l + r + 1) >> 1;
            ll c = ac + sum[i - 1] - sum[lb - 1], p = ap + sum[rb] - sum[mid];
            if (i % 2) {
                c += sum2[mid] - sum2[i - 1];
                p += sum[mid] - sum[i - 1] - (sum2[mid] - sum2[i - 1]);
            }
            else {
                c += sum[mid] - sum[i - 1] - (sum2[mid] - sum2[i - 1]);
                p += sum2[mid] - sum2[i - 1];
            }
            if (c < p) l = mid;
            else r = mid - 1;
        }
        ans = (ans + (l - i + 1) / 2) % mo;
    }
    return ans;
}

void run() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];
    for (int i = 1; i <= n; i++)
        if (i % 2) sum2[i] = sum2[i - 1] + a[i];
        else sum2[i] = sum2[i - 1];
    int l = 1, r = n;
    while (l < r) {
        int mid = (l + r) >> 1;
        if (sum[mid] > sum[n] - sum[mid]) r = mid;
        else l = mid + 1;
    }
    ll ans = n - r + 1;
    ans += solve(1, n, 0, 0);
    ans += solve(1, n - 1, a[n], 0);
    ans += solve(2, n, 0, a[1]);
    ans += solve(2, n - 1, a[n], a[1]);
    ans %= mo;
    cout << ans << endl;
}

int main() {
    ios::sync_with_stdio(false);
    int T;
    cin >> T;
    for (int I = 1; I <= T; I++) run();
    return 0;
}
