#include using namespace std; #define MOD (long long int)(998244353) #define ll long long int #define rep(i,n) for(int i=0; i<(int)(n); i++) #define reps(i,n) for(int i=1; i<=(int)(n); i++) #define REP(i,n) for(int i=n-1; i>=0; i--) #define REPS(i,n) for(int i=n; i>0; i--) #define FOR(i,a,b) for(int i=a; i<(int)(b); i++) #define ALL(x) (x).begin(),(x).end() #define RALL(a) (a).rbegin(), (a).rend() #define CLR(a) memset((a), 0 ,sizeof(a)) #define PB push_back #define MP make_pair #define SP << " " << const int INF = 1001001001; const ll LINF = 100100100100100100; const double EPS = 1e-10; const long double PI = acos(-1.0L); typedef pair PII; typedef pair PLL; typedef pair PDD; typedef pair PDI; typedef vector VI; typedef vector VVI; typedef vector VL; #define chmax(a,b) a = (((a)<(b))?(b):(a)) #define chmin(a,b) a = (((a)>(b))?(b):(a)) __attribute__((constructor)) void initial(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } signed main(){ ll n,q; cin>>n>>q; VL a(n); rep(i,n) cin>>a[i]; // ll dp[n+5][n+5]; // rep(i,n+5)rep(j,n+5) dp[i][j]=0LL; // dp[0][0]=1LL; ll dp[n+5]; rep(i,n+5) dp[i]=0LL; dp[0]=1LL; rep(i,n){ ll ep[n+5]; rep(j,n+5) ep[j]=0LL; rep(j,n){ ep[j]+=dp[j]*(a[i]-1)%MOD; // dp[i+1][j]+=dp[i][j]*(a[i]-1)%MOD; ep[j]%=MOD; ep[j+1]+=dp[j]; ep[j+1]%=MOD; } rep(j,n+5) dp[j]=ep[j]; } rep(i,q){ int b; cin>>b; cout<