#pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("inline") #pragma GCC target("avx2") #include #include #include #include using namespace std; using Mint = atcoder::modint998244353; vector q[500000]; int main() { int N, Q; scanf("%d%d",&N,&Q); int li = 0, ri = 0; for (long long a; ri < N; ++ri) { scanf("%lld",&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); li += 2; q[ri++] = move(r); } const auto &f = q[li]; for (int i = 0, b; i < Q; ++i) { scanf("%d", &b); printf("%u\n", f[b].val()); } }