#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int a = 0, w = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') w = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    a = (a << 1) + (a << 3) + (c ^ 48);
    c = getchar();
  }
  return a * w;
}
inline long long readll() {
  long long a = 0, w = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') w = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    a = (a << 1) + (a << 3) + (c ^ 48);
    c = getchar();
  }
  return a * w;
}
long long dp[(1 << 24) + 1], sum[(1 << 24) + 1], no[10], f[100];
const int mod = 1000000007;
int main() {
  long long n, m;
  n = readll();
  for (int i = (1); i <= (n); ++i) {
    f[i] = readll();
    sum[(1 << (i - 1))] = f[i];
  }
  m = readll();
  for (int i = (1); i <= (m); ++i) {
    no[i] = readll();
  }
  long long tot = (1ll << n) - 1;
  dp[0] = 1;
  for (int i = (1); i <= (tot); ++i) {
    sum[i] = sum[i - (i & (-i))] + sum[(i & (-i))];
    if (sum[i] == no[1] || sum[i] == no[2]) continue;
    for (int j = i; j; j -= (j & (-j))) {
      dp[i] += dp[i - (j & (-j))];
      if (dp[i] > mod) dp[i] -= mod;
    }
  }
  cout << dp[tot] << endl;
  return 0;
}
