#pragma GCC optimize("O3", "unroll-loops") #include using namespace std; #define ll long long #define ld long double constexpr ll mod = 998244353LL; int main(void){ int N, Q; cin >> N >> Q; vector A(N); for (int i = 0; i < N; ++i) cin >> A[i]; vector> DP(N + 1, vector(N + 1, 0LL)); DP[0][0] = 1LL; for (int i = 0; i < N; ++i){ for (int j = 0; j < N; ++j){ DP[i + 1][j] = (DP[i + 1][j] + DP[i][j] * (A[i] - 1) % mod) % mod; DP[i + 1][j + 1] = (DP[i + 1][j + 1] + DP[i][j]) % mod; } } while (Q--){ int B; cin >> B; cout << DP[N][B] << endl; } return 0; }