#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>
using namespace std;
const int md = 1000000007;
inline void add(int &a, int b) {
a += b;
if (a >= md) a -= md;
}
inline int mul(int a, int b) {
return (long long)a * b % md;
}
const int MAX = 1111111;
int fact[MAX], inv[MAX];
int C(int n, int k) {
if (n < 0 || k < 0 || k > n) return 0;
return mul(fact[n], mul(inv[k], inv[n - k]));
}
int f[2010][2], nf[2010][2];
int cnt[2010];
int ways[2010];
int ans[2010];
int main() {
fact[0] = inv[0] = 1;
for (int i = 1; i < MAX; i++) {
fact[i] = (long long)fact[i - 1] * i % md;
int x = 1, step = 1 << 30;
while (step > 0) {
x = (long long)x * x % md;
if (step & (md - 2)) x = (long long)x * fact[i] % md;
step >>= 1;
}
inv[i] = x;
}
int n;
scanf("%d", &n);
for (int i = 1; i <= 1000; i++) cnt[i] = 0;
for (int i = 0; i < n; i++) {
int foo;
scanf("%d", &foo);
cnt[foo]++;
}
for (int i = 0; i <= 2000; i++) f[i][0] = f[i][1] = 0;
f[0][0] = 1;
for (int t = 1; t <= 1000; t++) {
int addv = t + 1;
for (int u = 0; u <= 2000 / addv; u++) {
ways[u] = C(cnt[t], u);
}
for (int i = 0; i <= 2000; i++) nf[i][0] = nf[i][1] = 0;
for (int i = 0; i <= 2000; i++)
for (int p = 0; p <= 1; p++)
for (int it = 0, j = i; j <= 2000; it++, j += addv) {
add(nf[j][(p + it) & 1], mul(f[i][p], ways[it]));
}
for (int i = 0; i <= 2000; i++) {
f[i][0] = nf[i][0];
f[i][1] = nf[i][1];
}
}
for (int sw = 0; sw <= 2000; sw++) {
int res = 0;
for (int over = 0; over <= sw; over++)
for (int p = 0; p <= 1; p++) {
int ft = mul(f[over][p], C(sw - over + n - 1, n - 1));
if (p == 1) ft = md - ft;
add(res, ft);
}
ans[sw] = res;
}
int tt;
scanf("%d", &tt);
while (tt--) {
int foo;
scanf("%d", &foo);
printf("%d\n", ans[foo]);
}
return 0;
}
I2luY2x1ZGUgPGNzdHJpbmc+CiNpbmNsdWRlIDx2ZWN0b3I+CiNpbmNsdWRlIDxsaXN0PgojaW5jbHVkZSA8bWFwPgojaW5jbHVkZSA8c2V0PgojaW5jbHVkZSA8ZGVxdWU+CiNpbmNsdWRlIDxzdGFjaz4KI2luY2x1ZGUgPGJpdHNldD4KI2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGZ1bmN0aW9uYWw+CiNpbmNsdWRlIDxudW1lcmljPgojaW5jbHVkZSA8dXRpbGl0eT4KI2luY2x1ZGUgPHNzdHJlYW0+CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPGlvbWFuaXA+CiNpbmNsdWRlIDxjc3RkaW8+CiNpbmNsdWRlIDxjbWF0aD4KI2luY2x1ZGUgPGNzdGRsaWI+CiNpbmNsdWRlIDxjdGltZT4KI2luY2x1ZGUgPG1lbW9yeS5oPgojaW5jbHVkZSA8Y2Fzc2VydD4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpjb25zdCBpbnQgbWQgPSAxMDAwMDAwMDA3OwoKaW5saW5lIHZvaWQgYWRkKGludCAmYSwgaW50IGIpIHsKICBhICs9IGI7CiAgaWYgKGEgPj0gbWQpIGEgLT0gbWQ7Cn0KCmlubGluZSBpbnQgbXVsKGludCBhLCBpbnQgYikgewogIHJldHVybiAobG9uZyBsb25nKWEgKiBiICUgbWQ7Cn0KCmNvbnN0IGludCBNQVggPSAxMTExMTExOwoKaW50IGZhY3RbTUFYXSwgaW52W01BWF07CgppbnQgQyhpbnQgbiwgaW50IGspIHsKICBpZiAobiA8IDAgfHwgayA8IDAgfHwgayA+IG4pIHJldHVybiAwOwogIHJldHVybiBtdWwoZmFjdFtuXSwgbXVsKGludltrXSwgaW52W24gLSBrXSkpOwp9CgppbnQgZlsyMDEwXVsyXSwgbmZbMjAxMF1bMl07CgppbnQgY250WzIwMTBdOwppbnQgd2F5c1syMDEwXTsKaW50IGFuc1syMDEwXTsKCmludCBtYWluKCkgewogIGZhY3RbMF0gPSBpbnZbMF0gPSAxOwogIGZvciAoaW50IGkgPSAxOyBpIDwgTUFYOyBpKyspIHsKICAgIGZhY3RbaV0gPSAobG9uZyBsb25nKWZhY3RbaSAtIDFdICogaSAlIG1kOwogICAgaW50IHggPSAxLCBzdGVwID0gMSA8PCAzMDsKICAgIHdoaWxlIChzdGVwID4gMCkgewogICAgICB4ID0gKGxvbmcgbG9uZyl4ICogeCAlIG1kOwogICAgICBpZiAoc3RlcCAmIChtZCAtIDIpKSB4ID0gKGxvbmcgbG9uZyl4ICogZmFjdFtpXSAlIG1kOwogICAgICBzdGVwID4+PSAxOwogICAgfQogICAgaW52W2ldID0geDsKICB9CiAgaW50IG47CiAgc2NhbmYoIiVkIiwgJm4pOwogIGZvciAoaW50IGkgPSAxOyBpIDw9IDEwMDA7IGkrKykgY250W2ldID0gMDsKICBmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKykgewogICAgaW50IGZvbzsKICAgIHNjYW5mKCIlZCIsICZmb28pOwogICAgY250W2Zvb10rKzsKICB9CiAgZm9yIChpbnQgaSA9IDA7IGkgPD0gMjAwMDsgaSsrKSBmW2ldWzBdID0gZltpXVsxXSA9IDA7CiAgZlswXVswXSA9IDE7CiAgZm9yIChpbnQgdCA9IDE7IHQgPD0gMTAwMDsgdCsrKSB7CiAgICBpbnQgYWRkdiA9IHQgKyAxOwogICAgZm9yIChpbnQgdSA9IDA7IHUgPD0gMjAwMCAvIGFkZHY7IHUrKykgewogICAgICB3YXlzW3VdID0gQyhjbnRbdF0sIHUpOwogICAgfQogICAgZm9yIChpbnQgaSA9IDA7IGkgPD0gMjAwMDsgaSsrKSBuZltpXVswXSA9IG5mW2ldWzFdID0gMDsKICAgIGZvciAoaW50I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