#include <bits/stdc++.h>
const int M = 30;
const int MOD = 1e9 + 7;
int read() {
  int x = 0, f = 1;
  char c;
  while ((c = getchar()) < '0' || c > '9') {
    if (c == '-') f = -1;
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  return x * f;
}
int n, k, a[M], b[M], dp[1 << 24];
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  k = read();
  for (int i = 1; i <= k; i++) b[i] = read();
  dp[0] = 1;
  for (int i = 1; i < (1 << n); i++) {
    int sum = 0;
    for (int j = 1; j <= n; j++)
      if (i & (1 << j - 1)) {
        sum += a[j];
        dp[i] = (dp[i] + dp[i ^ (1 << j - 1)]) % MOD;
      }
    for (int j = 1; j <= k; j++)
      if (sum == b[j]) dp[i] = 0;
  }
  printf("%d\n", dp[(1 << n) - 1]);
}
