#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return (a ? gcd(b % a, a) : b); }
long long power(long long a, long long n) {
  long long p = 1;
  while (n > 0) {
    if (n % 2) {
      p = p * a;
    }
    n >>= 1;
    a *= a;
  }
  return p;
}
long long power(long long a, long long n, long long mod) {
  long long p = 1;
  while (n > 0) {
    if (n % 2) {
      p = p * a;
      p %= mod;
    }
    n >>= 1;
    a *= a;
    a %= mod;
  }
  return p % mod;
}
const int inf = 0x3f3f3f3f, mod = 1e9 + 7;
const int maxnn = (1 << 24) + 10;
const double PI = acos(-1.0);
int n, m, o, t;
int k[5];
int dp[maxnn], a[30];
int cun, all;
int main() {
  while (cin >> n) {
    for (int i = 0; i < n; i++) cin >> a[i];
    cin >> m;
    for (int i = 1; i <= m; i++) cin >> k[i];
    dp[0] = 1;
    for (int i = 1; i < (1 << n); i++) {
      int sum = 0;
      for (int j = 0; j < n; j++) {
        if ((i >> j) & 1) {
          sum += a[j];
          dp[i] = dp[i] + dp[i ^ (1 << j)];
          if (dp[i] >= mod) dp[i] -= mod;
        }
      }
      for (int j = 1; j <= m; j++)
        if (sum == k[j]) dp[i] = 0;
    }
    printf("%d\n", dp[(1 << n) - 1]);
  }
  return 0;
}
