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[] arr = new int[n + 1]; for (int i = 1; i <= n; i++) { arr[i] = sc.nextInt(); } long[][] dp = new long[n + 1][n + 1]; dp[0][0] = 1; for (int i = 1; i <= n; i++) { dp[i][0] = dp[i - 1][0] * (arr[i] - 1) % MOD; for (int j = 1; j <= i; j++) { dp[i][j] = dp[i - 1][j] * (arr[i] - 1) + dp[i - 1][j - 1]; dp[i][j] %= MOD; } } StringBuilder sb = new StringBuilder(); for (int i = 0; i < q; i++) { sb.append(dp[n][sc.nextInt()]).append("\n"); } System.out.print(sb); } }