#include<bits/stdc++.h> #define rep(i, a, b) for(int i = (a); i <= (b); i++) #define per(i, a, b) for(int i = (a); i >= (b); i--) #define pb push_back usingnamespacestd; typedeflonglong ll; constint mod = 998244353;
inlineintadd(constint &x, constint &y){ return x + y < mod ? x + y : x + y - mod; } inlineintsub(constint &x, constint &y){ return x - y < 0 ? x - y + mod : x - y; } inlineintmul(constint &x, constint &y){ return (int)((ll)x * y % mod); } inlineintksm(int x, int y = mod - 2){ int w = 1; for(; y; y >>= 1, x = mul(x, x)) if(y & 1) w = mul(w, x); return w; } namespace Poly { inlineintGet(int x){ int w = 1; for(; w <= x; w <<= 1); return w; } voidntt(vector<int> &A, int lmt, int opt){ A.resize(lmt + 5); for(int i = 0, j = 0; i < lmt; i++) { if(i > j) swap(A[i], A[j]); for(int k = lmt >> 1; (j ^= k) < k; k >>= 1); } vector<int> w(lmt >> 1); for(int mid = 1; mid < lmt; mid <<= 1) { w[0] = 1; int w0 = ksm(opt == 1 ? 3 : (mod + 1) / 3, (mod - 1) / mid / 2); for(int i = 1; i < mid; i++) w[i] = mul(w[i - 1], w0); for(int R = mid << 1, j = 0; j < lmt; j += R) for(int k = 0; k < mid; k++) { int x = A[j + k], y = mul(w[k], A[j + mid + k]); A[j + k] = add(x, y), A[j + mid + k] = sub(x, y); } } if(opt == -1) for(int mu = ksm(lmt), i = 0; i < lmt; i++) A[i] = mul(A[i], mu); } vector<int> Mul(constvector<int> &a, constvector<int> &b) { vector<int> A = a, B = b; int lmt = Get(a.size() + b.size() - 2); ntt(A, lmt, 1), ntt(B, lmt, 1); for(int i = 0; i < lmt; i++) A[i] = mul(A[i], B[i]); ntt(A, lmt, -1); return A.resize(a.size() + b.size() - 1), A; } vector<int> Inv(constvector<int> &a, int sz = -1) { if(sz == -1) sz = a.size(); vector<int> res; if(sz == 1) return res.pb(ksm(a[0])), res; res = Inv(a, (sz + 1) / 2); vector<int> tmp(a.begin(), a.begin() + sz); int lmt = Get(sz * 2 - 2); ntt(tmp, lmt, 1), ntt(res, lmt, 1); for(int i = 0; i < lmt; i++) res[i] = mul(sub(2, mul(res[i], tmp[i])), res[i]); ntt(res, lmt, -1); return res.resize(sz), res; } vector<int> Ln(constvector<int> &a) { vector<int> f, g = Inv(a); f.resize(a.size()); for(int i = 1; i < f.size(); i++) f[i - 1] = mul(i, a[i]); f[f.size() - 1] = 0, f = Mul(f, g), f.resize(a.size()); for(int i = f.size() - 1; i > 0; i--) f[i] = mul(f[i - 1], ksm(i)); f[0] = 0; return f; } }
constint N = 200010; int T, n, a[N], ans; vector<int> f, g;