# coding: utf-8 # Your code here! import sys readline = sys.stdin.readline read = sys.stdin.read n,q = map(int,readline().split()) *a, = map(int,readline().split()) *b, = map(int,readline().split()) import numpy as np MOD = 998244353 x = np.array([1],dtype=np.int64) for i in range(n): x = (a[i]-1)*(np.insert(x,i+1,0)) + np.insert(x,0,0) x %= MOD for i in b: print(x[i])