#include {ll@n,@q,a;VVI v(4d5,{1});rep(i,n)rd(a),v[i]={a-1,1};rep(18)rep(i,2d5)v[i]=atcoder::convolution<>(v[2i],v[2i+1]);rep(q)rd(a),wt(v[0][a]);}