#include using namespace std; using ll=long long; using vin=vector; using vll=vector; using vvin=vector>; using vvll=vector>; using vstr=vector; using vvstr=vector>; using vch=vector; using vvch=vector>; using vbo=vector; using vvbo=vector>; using vpii=vector>; using pqsin=priority_queue,greater>; #define mp make_pair #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep2(i,s,n) for(int i=(s);i<(int)(n);i++) #define all(v) v.begin(),v.end() #define decp(n) cout<>n>>q; vll a(n);rep(i,n)cin>>a[i]; vvll dp(n+1,vll(n+1));//dp[i][j]:i個目の箱まで殻球を一個ずつ取り出して色1がj個含まれる場合の数 dp[0][0]=1; rep(i,n)rep(j,n+1){ if(j>i+1)continue; dp[i+1][j]=(a[i]-1)*dp[i][j]; if(j>0)dp[i+1][j]+=dp[i][j-1]; dp[i+1][j]%=mod; } int b; vll ans(q); rep(i,q){ cin>>b; ans[i]=dp[n][b]; } rep(i,q)cout<