#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1, -1, -1, 1, 1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
template <class T>
inline T biton(T n, T pos) {
  return n | ((T)1 << pos);
}
template <class T>
inline T bitoff(T n, T pos) {
  return n & ~((T)1 << pos);
}
template <class T>
inline T ison(T n, T pos) {
  return (bool)(n & ((T)1 << pos));
}
template <class T>
inline T gcd(T a, T b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
template <typename T>
string NumberToString(T Number) {
  ostringstream second;
  second << Number;
  return second.str();
}
inline int nxt() {
  int aaa;
  scanf("%d", &aaa);
  return aaa;
}
inline long long int lxt() {
  long long int aaa;
  scanf("%lld", &aaa);
  return aaa;
}
inline double dxt() {
  double aaa;
  scanf("%lf", &aaa);
  return aaa;
}
template <class T>
inline T bigmod(T p, T e, T m) {
  T ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % m;
    p = (p * p) % m;
  }
  return (T)ret;
}
long long int ar[1000010];
long long int a[3];
long long int already[(1 << 24) + 10];
int dp[(1 << 24) + 10];
int n, tot;
int main() {
  n = nxt();
  tot = 1 << n;
  tot--;
  for (int i = 0; i < n; i++) {
    ar[i] = lxt();
  }
  int k = nxt();
  for (int i = 0; i < k; i++) a[i] = lxt();
  dp[0] = 1;
  for (int i = 1; i <= tot; i++) {
    int bt = __builtin_ctz(i);
    long long int sum = already[i] = already[i ^ (1 << bt)] + ar[bt];
    if (sum == a[0] || sum == a[1]) continue;
    for (int j = 0; j < n; j++) {
      if (ison(i, j) == 1) {
        dp[i] += dp[i ^ (1 << j)];
        if (dp[i] >= 1000000007) dp[i] -= 1000000007;
      }
    }
  }
  printf("%d\n", dp[tot]);
  return 0;
}
