import java.util.*; public class Main { static final int MOD = 998244353; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int q = sc.nextInt(); int[][] dp = new int[n + 1][n + 1]; dp[0][0] = 1; for (int i = 1; i <= n; i++) { long x = sc.nextInt(); for (int j = 0; j < i; j++) { dp[i][j] += (int)(dp[i - 1][j] * (x - 1) % MOD); dp[i][j] %= MOD; dp[i][j + 1] += dp[i - 1][j]; dp[i][j + 1] %= MOD; } } for (int i = 0; i < q; i++) { System.out.println(dp[n][sc.nextInt()]); } } }