N, Q = map(int, input().split()) A = [int(a) - 1 for a in input().split()] X = [[0] * (i+1) for i in range(N+1)] X[0][0] = 1 for i in range(N): for j in range(i+1): X[i+1][j] += X[i][j] * A[i] X[i+1][j+1] += X[i][j] B = [int(a) for a in input().split()] for a in B: print(X[-1][a])