#include <bits/stdc++.h>
using namespace std;
int read() {
  char ch = getchar();
  int x = 0, flag = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') flag *= -1;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
  return x * flag;
}
void write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) write(x / 10);
  putchar(x % 10 + 48);
}
const int Mod = (int)1e9 + 7, Maxn = 25;
int n, a[Maxn], k, k1, k2, val[1 << Maxn], dp[1 << Maxn];
void init() {
  n = read();
  for (int i = (1), i_end_ = (n); i <= i_end_; ++i) a[i] = read();
  k = read();
  if (k >= 1) k1 = read();
  if (k >= 2) k2 = read();
}
void solve() {
  if (k == 0) {
    int ans = 1;
    for (int i = (2), i_end_ = (n); i <= i_end_; ++i) ans = 1ll * ans * i % Mod;
    cout << ans << endl;
    return;
  }
  for (int i = (1), i_end_ = (n); i <= i_end_; ++i) val[1 << (i - 1)] = a[i];
  int ALL = (1 << n) - 1;
  dp[0] = 1;
  for (int i = (1), i_end_ = (ALL); i <= i_end_; ++i) {
    val[i] = val[i & (~((i) & -(i)))] + val[((i) & -(i))];
    if (val[i] == k1 || val[i] == k2) continue;
    for (int res = i; res; res ^= ((res) & -(res)))
      (dp[i] += dp[i & (~((res) & -(res)))]) %= Mod;
  }
  cout << dp[ALL] << endl;
}
int main() {
  init();
  solve();
  return 0;
}
