#include using namespace std; #include using namespace atcoder; using mint = modint998244353; mint fac[200000], facinv[200000]; void init(){ fac[0] = 1; for(int i = 1; i < 200000; i++) fac[i] = fac[i - 1] * i; facinv[200000 - 1] = 1 / fac[200000 - 1]; for(int i = 200000 - 2; i >= 0; i--) facinv[i] = facinv[i + 1] * (i + 1); } int main(){ init(); int n, m; cin >> n >> m; vector b(n); for(int i = 0; i < n; i++) cin >> b[i]; if(n == 1){ cout << (fac[m] * facinv[m - b[0]] * facinv[b[0]]).val() << endl; return 0; } vector a(n - 1); for(int i = 0; i < n - 1; i++) a[i] = b[i + 1] - b[i]; vector ret(1, 1); for(int i = 0; i < n - 1; i++){ vector v(m + 1); for(int j = 0; j <= m; j++){ if(a[i] + j < 0 || a[i] + 2 * j > m) continue; v[a[i] + 2 * j] = facinv[j] * facinv[a[i] + j]; } ret = convolution(ret, v); ret.resize(m + 1); } int x = b[0] + b[n - 1]; mint ans = 0; for(int i = 0; i * 2 <= x; i++){ mint c = ret[x - 2 * i] * facinv[i] * facinv[m - x + i]; ans += c; } ans *= fac[m]; cout << ans.val() << endl; }