#include #include #include #include #define REP(i, n) for (int i = 0, REP_N_ = int(n); i < REP_N_; ++i) using namespace std; using Mint = atcoder::modint998244353; vector q[20000]; int main() { int N, Q; scanf("%d%d", &N, &Q); int li = 0, ri = 0; REP(i, N) { int a; scanf("%d", &a); q[ri++] = vector{Mint(a - 1), Mint(1)}; } const int z = N + 1; while (ri - li > 1) { auto r = atcoder::convolution(move(q[li]), move(q[li + 1])); if (int(r.size()) > z) r.resize(z); while (r.back() == 0) r.pop_back(); li += 2; q[ri++].swap(r); } const auto &f = q[li]; REP(i, Q) { int b; scanf("%d", &b); printf("%u\n", f[b].val()); } }