#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;

typedef long long ll;

const ll maxn=100003+100,maxm=125003*5,inf=1e15,mod=998244353;

int n,m;
ll a[200030],suma[200030],sumb[200030][2];

int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&n);
		ll now=1,ans=0;
		for(int i=1;i<=n;i++)
		{
			scanf("%I64d",&a[i]);
			suma[i]=suma[i-1]+a[i];
			sumb[i][1]=sumb[i-1][1]+now*a[i];//odd
			sumb[i][0]=sumb[i-1][0]-now*a[i];//even
			now=now*(-1);
		}
		if(n==1)
		{
			printf("1\n");
			continue;
		}
		for(int i=0;i<=n;i++)
		{
			ll now=-suma[i];
			if(now+suma[n]-suma[i]<0) break;
			ll l=0,r=(n-i)/2,nowans=-1;
			while(l<=r)
			{
				ll mid=(l+r)/2;
				if(now+sumb[i+mid*2][(i+1)&1]-sumb[i][(i+1)&1]+suma[n]-suma[i+mid*2]>0)
				{
					nowans=mid;
					l=mid+1;
				}
				else r=mid-1;
			}
			ans=(ans+nowans+1)%mod;
			//printf("%d:%I64d %lld\n",i,i+nowans*2,nowans);
		}
		//printf("%lld\n",ans);
		for(int i=3;i<=n;i++)
		{
			ll now=a[1]-(suma[i]-suma[1]);
			if(now+suma[n]-suma[i]<0) break;
			ll l=0,r=(n-i)/2,nowans=-1;
			while(l<=r)
			{
				ll mid=(l+r)/2;
				if(now+sumb[i+mid*2][(i+1)&1]-sumb[i][(i+1)&1]+suma[n]-suma[i+mid*2]>0)
				{
					nowans=mid;
					l=mid+1;
				}
				else r=mid-1;
			}
			ans=(ans+nowans+1)%mod;
			//printf("%d:%I64d %lld\n",i,i+nowans*2,nowans);
		}
		for(int i=0;i<=n-3;i++)
		{
			ll now=-suma[i]-a[n]+a[n-1]+a[n-2];
			if(now+suma[n-3]-suma[i]<0) break;
			ll l=0,r=(n-3-i)/2,nowans=-1;
			while(l<=r)
			{
				ll mid=(l+r)/2;
				if(now+sumb[i+mid*2][(i+1)&1]-sumb[i][(i+1)&1]+suma[n-3]-suma[i+mid*2]>0)
				{
					nowans=mid;
					l=mid+1;
				}
				else r=mid-1;
			}
			ans=(ans+nowans+1)%mod;
			//printf("%d:%I64d %lld\n",i,i+nowans*2,nowans);
		}
		for(int i=3;i<=n-3;i++)
		{
			ll now=a[1]-(suma[i]-suma[1])-a[n]+a[n-1]+a[n-2];
			if(now+suma[n-3]-suma[i]<0) break;
			ll l=0,r=(n-3-i)/2,nowans=-1;
			while(l<=r)
			{
				ll mid=(l+r)/2;
				if(now+sumb[i+mid*2][(i+1)&1]-sumb[i][(i+1)&1]+suma[n-3]-suma[i+mid*2]>0)
				{
					nowans=mid;
					l=mid+1;
				}
				else r=mid-1;
			}
			ans=(ans+nowans+1)%mod;
			//printf("%d:%I64d %lld\n",i,i+nowans*2,nowans);
		}
		//printf("%I64d\n",ans);
		for(int i=2;i<=n-2;i++) if(suma[i]-(suma[n]-suma[i])>0) ans=(ans+1)%mod;
		printf("%I64d\n",ans);
	}
	return 0;
} 