#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; long long dp[6060][6060] = {}; int main() { int n, q; cin >> n >> q; dp[0][0] = 1; for (int i = 1; i <= n; i++) { long long a; cin >> a; for (int j = 0; j <= n; j++) { dp[i][j] += dp[i - 1][j] * (a - 1); dp[i][j] %= 998244353; if (j != 0) { dp[i][j] += dp[i - 1][j - 1]; dp[i][j] %= 998244353; } } } for (int i = 0; i < q; i++) { int b; cin >> b; cout << dp[n][b] << endl; } }