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