
f[x][0/1]为最大值为x的合法序列个数,
f[x][0]:包含0~x, f[x][1]:包含0~x-2和x
#include<bits/stdc++.h>
using namespace std;
#define fr first
#define se second
#define et0 exit(0);
#define rep(i, a, b) for(int i = (a); i <= (b); i ++)
#define rrep(i, a, b) for(int i = (a); i >= (b); i --)
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef unsigned long long ULL;
const int INF = 0X3f3f3f3f, N = 2e6 + 10, MOD = 998244353;
const double eps = 1e-7;
void work() {
int n;
cin >> n;
vector<vector<LL>> f(n + 4, vector<LL>(2));
// 最大值为x的合法序列个数, f[x][0]:包含0~x, f[x][1]:包含0~x-2和x
f[0][0] = 1;
rep(i, 1, n) {
int x;
cin >> x;
x++;
f[x][0] += f[x][0] + f[x - 1][0];
f[x][1] += f[x][1];
f[x + 2][1] += f[x + 2][1];
if (x > 1) f[x][1] += f[x - 2][0];
f[x][0] %= MOD, f[x][1] %= MOD, f[x + 2][1] %= MOD;
}
LL ans = 0;
rep(i, 1, n + 1) ans += f[i][0] + f[i][1], ans %= MOD;
cout << ans << endl;
}
signed main() {
int test;
cin >> test;
while (test--) {
work();
}
return 0;
}