#include<bits/stdc++.h>
#define LL long long
#define dl double
#define P pair<int,int>
#define SZ(a) ((int)a.size())
using namespace std;

const int N = 2e5 + 10;
const int mod = 998244353;

int T,n,a[N];
LL s[N][2],b[N][2];
LL ans;

LL get(int l,int r){
  LL x = s[r][0] - s[l - 1][0],y = s[r][1] - s[l - 1][1];
  if(l & 1)return y - x;
  else return x - y;
}
void work1(){
  for(int i = 1;i < n;i++){
    int l = i,r = n;
    while(l != r){
      int j = (l + r) / 2 + 1;
      if(b[j][0] + b[j][1] - s[i][0] - s[i][1] + get(i + 1,j - 1) <= 0)r = j - 1;
      else l = j;
    }
    if(l <= i)continue;
    // cout << i << " " << l << endl;
    if((l - i - 1) % 2)ans += (l - i) / 2;
    else ans += (l - i + 1) / 2;
    ans %= mod;
  }
  // cout << ans << endl;
}
void work2(){
  for(int i = 1;i < n;i++){
    int l = i,r = n - 1;
    while(l != r){
      int j = (l + r) / 2 + 1;
      if(b[j][0] + b[j][1] - 2 * a[n] - s[i][0] - s[i][1] + get(i + 1,j - 1) <= 0)r = j - 1;
      else l = j;
    }
    if(l <= i)continue;
    if((l - i - 1) % 2)ans += (l - i) / 2;
    else ans += (l - i + 1) / 2;
    ans %= mod;
  }
  // cout << ans << endl;
}
void work3(){
  for(int i = 2;i < n;i++){
    int l = i,r = n;
    while(l != r){
      int j = (l + r) / 2 + 1;
      if(b[j][0] + b[j][1] - s[i][0] - s[i][1] + 2 * a[1] + get(i + 1,j - 1) <= 0)r = j - 1;
      else l = j;
    }
    if(l <= i)continue;
    if((l - i - 1) % 2)ans += (l - i) / 2;
    else ans += (l - i + 1) / 2;
    ans %= mod;
  }
  // cout << ans << endl;
}
void work4(){
  for(int i = 2;i < n;i++){
    int l = i,r = n - 1;
    while(l != r){
      int j = (l + r) / 2 + 1;
      if(b[j][0] + b[j][1] - 2 * a[n] - s[i][0] - s[i][1] + 2 * a[1] + get(i + 1,j - 1) <= 0)r = j - 1;
      else l = j;
    }
    if(l <= i)continue;
    if((l - i - 1) % 2)ans += (l - i) / 2;
    else ans += (l - i + 1) / 2;
    ans %= mod;
  }
  // cout << ans << endl;
}
void work5(){
  for(int i = 1;i <= n + 1;i++){
    if(s[i - 1][0] + s[i - 1][1] > b[i][0] + b[i][1])ans++;
    ans %= mod;
  }
  // cout << ans << endl;
}

int main(){
  // freopen("in.txt","r",stdin);
  // freopen("o.txt","w",stdout);
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cin >> T;
  while(T--){
    cin >> n;for(int i = 1;i <= n;i++)cin >> a[i];
    for(int i = 1;i <= n;i++){
      s[i][0] = s[i - 1][0];
      s[i][1] = s[i - 1][1];
      s[i][i & 1] += a[i];
    }
    b[n + 1][0] = b[n + 1][1] = 0;
    for(int i = n;i >= 1;i--){
      b[i][0] = b[i + 1][0];
      b[i][1] = b[i + 1][1];
      b[i][i & 1] += a[i];
    }
    ans = 0;
    work1();work2();work3();work4();work5();
    cout << ans % mod << endl;
  }
  return 0;
}
/*
4种情况
*/