#include <bits/stdc++.h>
const int mo = 1000000007, N = 24;
int f[1 << N], s[1 << N], v[1 << N];
int n, k, a0 = -1, a1 = -1;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", v + (1 << i));
  scanf("%d", &k);
  if (k == 0) {
    int ans = 1;
    for (int i = 1; i <= n; ++i) ans = (long long)ans * i % mo;
    printf("%d\n", ans);
    return 0;
  }
  scanf("%d", &a0);
  if (k == 2) scanf("%d", &a1);
  f[0] = 1;
  for (int i = 1, j; i < 1 << n; ++i) {
    s[i] = s[i ^ (i & -i)] + v[i & -i];
    if (s[i] > mo) s[i] = mo;
    if (s[i] == a0 || s[i] == a1) continue;
    for (j = i; j; j ^= j & -j) f[i] = (f[i] + f[i ^ (j & -j)]) % mo;
  }
  printf("%d\n", f[(1 << n) - 1]);
  return 0;
}
