#include <bits/stdc++.h>

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 2e5 + 10;
const ll mod = 998244353;

int n;
ll a[maxN], pre[maxN];

void solve()
{
    cin >> n;
    for1(i, n)
    {
        cin >> a[i];
    }
    //case works
    if (n == 1)
    {
        cout << 1 << "\n";
        return;
    }
    ll ans = 0, sum = 0;
    for1(i, n)
    {
        sum += a[i];
    }
    pre[1] = a[1];
    pre[2] = a[2];
    fore(i, 3, n)
    {
        pre[i] = pre[i - 2] + a[i];
    }
    ll cur = 0;
    for1(i, n - 1)
    {
        int l = 0, r = (n - i + 1) / 2;
        cur += a[i];
        if (cur * 2 >= sum)
        {
            break;
        }
        while (r - l > 1)
        {
            int mid = (l + r) / 2;
            if ((pre[i + mid * 2] - pre[i] + cur) * 2 < sum)
            {
                l = mid;
            }
            else
            {
                r = mid;
            }
        }
        ans = (ans + l + 1) % mod;
    }
    cur = a[n];
    for1(i, n - 2)
    {
        int l = 0, r = (n - i) / 2;
        cur += a[i];
        if (cur * 2 >= sum)
        {
            break;
        }
        while (r - l > 1)
        {
            int mid = (l + r) / 2;
            if ((pre[i + mid * 2] - pre[i] + cur) * 2 < sum)
            {
                l = mid;
            }
            else
            {
                r = mid;
            }
        }
        ans = (ans + l + 1) % mod;
    }
    cur = 0;
    fore(i, 2, n - 1)
    {
        int l = 0, r = (n - i + 1) / 2;
        cur += a[i];
        if (cur * 2 >= sum)
        {
            break;
        }
        while (r - l > 1)
        {
            int mid = (l + r) / 2;
            if ((pre[i + mid * 2] - pre[i] + cur) * 2 < sum)
            {
                l = mid;
            }
            else
            {
                r = mid;
            }
        }
        ans = (ans + l + 1) % mod;
    }
    cur = a[n];
    fore(i, 2, n - 2)
    {
        int l = 0, r = (n - i) / 2;
        cur += a[i];
        if (cur * 2 >= sum)
        {
            break;
        }
        while (r - l > 1)
        {
            int mid = (l + r) / 2;
            if ((pre[i + mid * 2] - pre[i] + cur) * 2 < sum)
            {
                l = mid;
            }
            else
            {
                r = mid;
            }
        }
        ans = (ans + l + 1) % mod;
    }
    cur = 0;
    for1(i, n)
    {
        cur += a[i];
        if (cur * 2 > sum)
        {
            ans = (ans + 1) % mod;
        }
    }
    cout << ans << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    cin >> T;
    while (T--)
    {
        solve();
    }
    return 0;
}
