#if defined(_USE_PCH_)
#include "pch.hpp"
#else
#include <bits/stdc++.h>
#endif
#define RNG(V_, A_, B_, ...) for(int V_=(A_), V_##_END=(B_) __VA_OPT__(,) __VA_ARGS__; V_<=V_##_END; V_++)
#define IRNG(V_, A_, B_, ...) for(int V_=(A_), V_##_END=(B_) __VA_OPT__(,) __VA_ARGS__; V_>=V_##_END; V_--)
#ifdef _WIN32
#define long int64_t
#endif
#define fi first
#define se second
#define _UN using namespace
using namespace std;
typedef pair<int,int> pii;
typedef __int128 i128;
const int MAXN=2e6+10; const long MOD=998244353;
void addto(long& x,long y){ x=(x+y)%MOD; }
int n,A[MAXN],nnd;
pii st[21][MAXN];
pii qry(int l,int r){ int t=__lg(r-l+1); return min(st[t][l],st[t][r-(1<<t)+1]); }
long F[MAXN]; int sz[MAXN];
int solve(int l,int r){
    if(l>r) return 0;
    int u=++nnd;
    if(l==r){ F[u]=1,sz[u]=1; return u; }
    int p=qry(l,r).se;
    int ls=solve(l,p-1),rs=solve(p+1,r);
    sz[u]=sz[ls]+sz[rs]+1;
    F[u]=(2*F[ls]*F[rs]%MOD+F[ls]*(2+sz[rs])%MOD+F[rs]*(2+sz[ls])%MOD+1)%MOD;
    return u;
}
void case_main(){
    cin>>n;
    RNG(i,1,n) cin>>A[i];
    RNG(i,1,n) st[0][i]={A[i],i};
    RNG(t,1,__lg(n)){
        RNG(i,1,n-(1<<t)+1) st[t][i]=min(st[t-1][i],st[t-1][i+(1<<(t-1))]);
    }
    nnd=0;
    solve(1,n);
    auto ans=(F[1]+n+1)%MOD;
    cout<<ans<<"\n";
}
int main(){
#if defined(_LOCAL_)
    freopen("in","r",stdin);
    freopen("out","w",stdout);
//  freopen("/dev/null","w",stderr);
#else
    freopen("destsurr.in","r",stdin);
    freopen("destsurr.out","w",stdout);
#endif
    ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
    int cas; cin>>cas;
    RNG(_,1,cas) case_main();
}