#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(2,vll(n+1));//dp[i][j]:i個目の箱まで殻球を一個ずつ取り出して色1がj個含まれる場合の数 dp[0][0]=1; rep2(i,1,n+1)rep(j,n+1){ if(j>i)continue; dp[i%2][j]=(a[i-1]-1)*dp[(i-1)%2][j]; if(j>0)dp[i%2][j]+=dp[(i-1)%2][j-1]; dp[i%2][j]%=mod; } int b; vll ans(q); rep(i,q){ cin>>b; ans[i]=dp[n%2][b]; } rep(i,q)cout<