#include <bits/stdc++.h>
int constexpr maxn = 28;
int constexpr maxm = maxn / 2;
long long constexpr mo = 1000000007;
long long fact[maxn];
long long pow3[maxm];
long long a[maxn];
long long bad[3];
int n, k;
void init_fact() {
  fact[0] = 1;
  for (int i = 1; i < maxn; i++) fact[i] = (fact[i - 1] * i) % mo;
}
void init_pow3() {
  pow3[0] = 1;
  for (int i = 1; i < maxm; i++) pow3[i] = pow3[i - 1] * 3;
}
using pair_type = std::pair<long long, long long>;
using key_type = pair_type;
struct key_hash {
  std::size_t operator()(key_type const& key) const {
    return std::hash<long long>()(key.first) ^
           (std::hash<long long>()(key.second) << 2);
  }
};
struct key_equal {
  bool operator()(key_type const& k1, key_type const& k2) const {
    return k1 == k2;
  }
};
long long calc(int u) {
  int lhalf = n / 2;
  int rhalf = n - lhalf;
  std::unordered_map<key_type, long long, key_hash, key_equal> right;
  for (int i = 0; i < (1 << rhalf); i++) {
    long long sum = 0, tot = 0;
    for (int j = 0; j < rhalf; j++)
      if ((i >> j) & 1) {
        sum += a[j + lhalf];
        tot++;
      }
    right[{sum, tot}]++;
  }
  long long ret = 0;
  for (int i = 0; i < (1 << lhalf); i++) {
    long long sum = 0, tot = 0;
    for (int j = 0; j < lhalf; j++)
      if ((i >> j) & 1) {
        sum += a[j];
        tot++;
      }
    if (sum > u) continue;
    for (int j = 0; j + tot <= n && j <= rhalf; j++) {
      auto tmp = right[{u - sum, j}];
      if (tmp) {
        long long ti = (fact[tot + j] * fact[n - tot - j]) % mo;
        ret = (ret + (tmp * ti) % mo) % mo;
      }
    }
  }
  return ret;
}
long long calc2(int u1, int u2) {
  u2 -= u1;
  int lhalf = n / 2;
  int rhalf = n - lhalf;
  std::unordered_map<
      key_type, std::unordered_map<key_type, long long, key_hash, key_equal>,
      key_hash, key_equal>
      right;
  for (int i = 0; i < pow3[rhalf]; i++) {
    long long sum1 = 0, tot1 = 0, sum2 = 0, tot2 = 0;
    for (int j = 0, t = i; t; j++, t /= 3) {
      if (t % 3 == 1) {
        sum1 += a[j + lhalf];
        tot1++;
      } else if (t % 3 == 2) {
        sum2 += a[j + lhalf];
        tot2++;
      }
    }
    right[{sum1, tot1}][{sum2, tot2}]++;
  }
  long long ret = 0;
  for (int i = 0; i < pow3[lhalf]; i++) {
    long long sum1 = 0, tot1 = 0, sum2 = 0, tot2 = 0;
    for (int j = 0, t = i; t; j++, t /= 3) {
      if (t % 3 == 1) {
        sum1 += a[j];
        tot1++;
      } else if (t % 3 == 2) {
        sum2 += a[j];
        tot2++;
      }
    }
    if (sum1 > u1 || sum2 > u2) continue;
    for (int j = 0; j + tot1 + tot2 <= n && j <= rhalf; j++) {
      if (right.find({u1 - sum1, j}) == right.end()) continue;
      for (int k = 0; k + j + tot1 + tot2 <= n && k <= rhalf; k++) {
        auto tmp = right[{u1 - sum1, j}][{u2 - sum2, k}];
        if (tmp) {
          long long ti = (((fact[tot1 + j] * fact[tot2 + k]) % mo) *
                          fact[n - tot1 - tot2 - j - k]) %
                         mo;
          ret = (ret + (tmp * ti)) % mo;
        }
      }
    }
  }
  return ret;
}
int main() {
  std::ios::sync_with_stdio(false);
  init_fact();
  init_pow3();
  std::cin >> n;
  for (int i = 0; i < n; i++) std::cin >> a[i];
  std::cin >> k;
  for (int i = 0; i < k; i++) std::cin >> bad[i];
  if (k == 2 && bad[0] > bad[1]) std::swap(bad[0], bad[1]);
  if (!k) {
    std::cout << fact[n] << '\n';
  } else if (k == 1) {
    long long ans = fact[n] - calc(bad[0]);
    ans = ((ans % mo) + mo) % mo;
    std::cout << ans << '\n';
  } else {
    long long ans =
        fact[n] - calc(bad[0]) - calc(bad[1]) + calc2(bad[0], bad[1]);
    ans = ((ans % mo) + mo) % mo;
    std::cout << ans << '\n';
  }
}
