#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.141592653589793238462643383279502884197;
long long fac[1] = {1}, inv[1] = {1};
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long mp(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % 1000000007;
    a = a * a % 1000000007;
    b >>= 1;
  }
  return ret;
}
long long cmb(long long r, long long c) {
  return fac[r] * inv[c] % 1000000007 * inv[r - c] % 1000000007;
}
priority_queue<int, vector<int>, greater<int>> pq;
vector<int> v;
int dp[1 << 24];
int nn;
int vec[24];
int kk[2];
int main() {
  int n, k, ne;
  scanf("%d", &n);
  nn = 1 << n;
  for (int i = 0; i < n; i++) scanf("%d", &vec[i]);
  scanf("%d", &k);
  kk[0] = kk[1] = -1;
  for (int i = 0; i < k; i++) scanf("%d", &kk[i]);
  long long sum;
  dp[0] = 1;
  for (int i = 0; i < nn; i++) {
    sum = 0;
    for (int j = 0; j < n; j++) sum += vec[j] * !!(i & (1 << j));
    dp[i] *= (sum != kk[0]) * (sum != kk[1]);
    for (int j = 0; j < n; j++) {
      ne = i | (1 << j);
      dp[ne] += dp[i] * (i != ne);
      dp[ne] -= (dp[ne] >= 1000000007) * 1000000007;
    }
  }
  printf("%d\n", dp[nn - 1]);
}
