#include <iostream>
#include <algorithm>

constexpr int N = 200005;
constexpr int p = 998244353;

int add(int x, int y) { return (x += y) >= p ? x - p : x; }

int T, n;
int a[N];
long long pre[2][N], suf[N];

int solve(int l, int r, long long now) {
    if (l == r + 1) return now > 0;
    int ans = 0;
    for (int i = l; i <= r; ++i) {
        now -= a[i];
        long long t = now + suf[i + 1] - suf[r + 1];
        if (t > 0) ans = add(ans, 1);
        if (i >= r - 1) continue;
        ans = add(ans, (std::lower_bound(pre[i & 1] + i + 2, pre[i & 1] + r + 1, t + pre[i & 1][i]) - pre[i & 1] - i - 1) >> 1);
    }
    return ans;
}

int main() {
    std::ios::sync_with_stdio(false), std::cin.tie(nullptr);
    std::cin >> T;
    while (T--) {
        std::cin >> n;
        for (int i = 1; i <= n; ++i) {
            std::cin >> a[i];
            pre[0][i] = pre[0][i - 1];
            pre[1][i] = pre[1][i - 1];
            pre[i & 1][i] += a[i] << 1;
        }
        if (n <= 3) { std::cout << (1 << n - 1) << '\n'; continue; }
        suf[n + 1] = 0;
        for (int i = n; i; --i) suf[i] = suf[i + 1] + a[i];
        int ans = 0;
        ans = add(ans, solve(1, n - 1, a[n]));
        ans = add(ans, solve(1, n - 2, a[n - 1] - a[n]));
        ans = add(ans, solve(2, n - 1, a[1] + a[n]));
        ans = add(ans, solve(2, n - 2, a[1] + a[n - 1] - a[n]));
        long long now = 0;
        for (int i = 1; i <= n; ++i) {
            now += a[i];
            long long t = now - suf[i + 1];
            if (t > 0) ans = add(ans, 1);
        }
        std::cout << ans << '\n';
    }
    return 0;
}
