#include <bits/stdc++.h>
const int INF = 2000000005;
const long long BIG_INF = 2000000000000000005;
const int mod = 1000000007;
const int P = 31;
const long double PI = 3.141592653589793238462643;
const double eps = 1e-9;
using namespace std;
vector<pair<int, int> > dir = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
bool valid(int x, int y, int n, int m) {
  return x >= 0 && y >= 0 && x < n && y < m;
}
mt19937 rng(1999999973);
const int N = 25;
int n, a[N], k, x[2], fact[N];
void init() {
  fact[0] = 1;
  for (int i = 1; i < N; i++) {
    fact[i] = (((long long)fact[i - 1] * (long long)i) % (long long)mod);
  }
}
int sum[1 << 24], col[1 << 24];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  init();
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  cin >> k;
  for (int i = 0; i < k; i++) cin >> x[i];
  sort(x, x + k);
  int ans = fact[n];
  for (int i = 0; i < n; i++) col[1 << i] = 1;
  for (int mask = 1; mask < (1 << n); mask++) {
    sum[mask] = sum[mask & (mask - 1)] + a[__builtin_ctz(mask)];
    if (sum[mask] == x[0] || sum[mask] == x[1]) {
      ans += mod - (int)(((long long)col[mask] *
                          (long long)fact[n - __builtin_popcount(mask)]) %
                         (long long)mod);
      if (ans >= mod) ans -= mod;
      continue;
    }
    int cur = mask ^ ((1 << n) - 1);
    while (cur > 0) {
      col[mask ^ (1 << __builtin_ctz(cur))] += col[mask];
      if (col[mask ^ (1 << __builtin_ctz(cur))] >= mod)
        col[mask ^ (1 << __builtin_ctz(cur))] -= mod;
      cur &= cur - 1;
    }
  }
  cout << ans;
  return 0;
}
