#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    x = (x << 1) + (x << 3) + ch - '0';
  return x * f;
}
const int N = 25;
const int M = (1 << 25);
const int P = 1e9 + 7;
int a1, a2, sum[M], dp[M];
int main() {
  int n = read();
  for (int i = 0; i < n; ++i) sum[1 << i] = read();
  int m = read();
  if (m > 0) a1 = read();
  if (m > 1) a2 = read();
  dp[0] = 1;
  int bit = (1 << n);
  for (int i = 1; i < bit; ++i) {
    int k = i & -i;
    sum[i] = sum[i ^ k] + sum[k];
    if (sum[i] == a1 || sum[i] == a2) continue;
    for (int j = i, p; j; j ^= p) {
      p = j & -j, (dp[i] += dp[i ^ p]) >= P ? dp[i] -= P : 0;
    }
  }
  printf("%d\n", dp[(1 << n) - 1]);
  return 0;
}
