//#pragma GCC optimize(2)
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <utility>
#include <stack>
#include <deque>
#include <queue>
#include <string>
#include <cctype>
#include <sstream>
#include <map>
#include <random>
#include <unordered_map>
#include <unordered_set>
//#define LOCAL
#define ll long long
#define pdd pair<double, double>
#define pii pair<int, int>
#define pli pair<ll, int>
//#define mp(x, y) make_pair(x, y)
//#define ld long double
//#define int ll
#define maxn 200005
#define maxm 200005
#define maxk 5004
#define maxprime 10000007
#define PI 3.14159265358979323846
#define mod 998244353
#define eps 1e-6
#define INF 100000000000
using namespace std;

int n;
ll a[maxn], s[maxn], odd[maxn], even[maxn];

signed main()
{
#ifdef LOCAL
    freopen("data.in.txt","r",stdin);
    freopen("data.out.txt","w",stdout);
#endif
    int t; cin >> t;
    while(t--)
    {
        cin >> n;
        for(int i = 1; i <= n; i++)
        {
            scanf("%lld", &a[i]);
            s[i] = s[i-1]+a[i];
        }
        odd[1] = a[1];
        for(int i = 3; i <= n; i+=2) odd[(i+1)/2] = odd[(i+1)/2-1]+a[i];
        for(int i = 2; i <= n; i+=2) even[i/2] = even[i/2-1]+a[i];

        ll ans = 1;
        for(int i = 1; i <= 2; i++)
        {
            for(int j = i; j <= n; j++)
            {
                if(2*(s[j]-s[i-1]) < s[n])
                {
                    if(j%2==1)
                    {
                        int l = (j+1)/2, r = (n+1)/2+1, mid = (l+r)/2;
                        while(l < r-1)
                        {
                            if(2*(s[j]-s[i-1]+odd[mid]-odd[(j+1)/2]) >= s[n]) r = mid;
                            else l = mid;
                            mid = (l+r)/2;
                        }
                        ans = (ans+l-(j+1)/2+1)%mod;
                    }
                    else
                    {
                        int l = j/2, r = n/2+1, mid = (l+r)/2;
                        while(l < r-1)
                        {
                            if(2*(s[j]-s[i-1]+even[mid]-even[j/2]) >= s[n]) r = mid;
                            else l = mid;
                            mid = (l+r)/2;
                        }
                        ans = (ans+l-j/2+1)%mod;
                    }
                }
                if(j < n-2 && 2*(s[j]-s[i-1]+a[n]) < s[n])
                {
                    if(j%2==1)
                    {
                        int l = (j+1)/2, r = n/2, mid = (l+r)/2;
                        while(l < r-1)
                        {
                            if(2*(s[j]-s[i-1]+odd[mid]-odd[(j+1)/2]+a[n]) >= s[n]) r = mid;
                            else l = mid;
                            mid = (l+r)/2;
                        }
                        ans = (ans+l-(j+1)/2+1) % mod;
                    }
                    else
                    {
                        int l = j/2, r = (n+1)/2-1, mid = (l+r)/2;
                        while(l < r-1)
                        {
                            if(2*(s[j]-s[i-1]+even[mid]-even[j/2]+a[n]) >= s[n]) r = mid;
                            else l = mid;
                            mid = (l+r)/2;
                        }
                        ans = (ans+l-j/2+1)%mod;
                    }
                }
            }
        }
        for(int i = 3; i <= n; i++)
            ans += (2*(s[n]-s[i-1]) < s[n]);
        cout << ans%mod << endl;
    }
    return 0;
}