#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 10;
const int M = 1000000007;
const double PI = atan(1) * 4;
const int oo = 1000000000;
int n, v[25], fact[25], k, x[2], dp[1 << 24][2][2], match;
map<pair<int, int>, map<pair<int, int>, int> > mp;
map<pair<int, int>, map<pair<int, int>, int> >::iterator it;
map<pair<int, int>, int>::iterator it2;
void mim(int u, int t, int s1, int c1, int s2, int c2, bool f) {
  if (u == t) {
    if (!f) {
      ++mp[pair<int, int>(s1, s2)][pair<int, int>(c1, c2)];
      return;
    }
    int a = x[0] - s1;
    int b = x[1] - x[0] - s2;
    if ((it = mp.find(pair<int, int>(a, b))) != mp.end()) {
      map<pair<int, int>, int> &p = it->second;
      for (it2 = p.begin(); it2 != p.end(); ++it2) {
        a = it2->first.first;
        b = it2->first.second;
        int cur = 1ll * fact[c1 + a] * fact[c2 + b] % M;
        cur = 1ll * cur * fact[n - c1 - a - c2 - b] % M;
        cur = 1ll * cur * it2->second % M;
        match = (match + cur) % M;
      }
    }
    return;
  }
  mim(u + 1, t, s1, c1, s2, c2, f);
  if (s1 + v[u] <= x[0]) mim(u + 1, t, s1 + v[u], c1 + 1, s2, c2, f);
  if (s2 + v[u] <= x[1] - x[0]) mim(u + 1, t, s1, c1, s2 + v[u], c2 + 1, f);
}
int go(int u, int s, int ct, int &tr) {
  if (u == n) {
    if (s != tr) return 0;
    return (1ll * fact[ct] * fact[n - ct]) % M;
  }
  if (s + v[u] <= tr)
    return (go(u + 1, s, ct, tr) + go(u + 1, s + v[u], ct + 1, tr)) % M;
  return go(u + 1, s, ct, tr);
}
int main() {
  cin >> n;
  fact[0] = 1;
  for (int i = 1; i < 25; ++i) fact[i] = (1ll * i * fact[i - 1]) % M;
  for (int i = 0; i < n; ++i) cin >> v[i];
  cin >> k;
  for (int i = 0; i < k; ++i) cin >> x[i];
  if (k > 1 && x[0] > x[1]) swap(x[0], x[1]);
  int ans = fact[n];
  if (k) {
    ans -= go(0, 0, 0, x[0]);
    if (ans < 0) ans += M;
    if (k > 1) {
      ans -= go(0, 0, 0, x[1]);
      if (ans < 0) ans += M;
      mim(0, n / 2, 0, 0, 0, 0, 0);
      mim(n / 2, n, 0, 0, 0, 0, 1);
      ans = (ans + match) % M;
    }
  }
  cout << ans << endl;
}
