#include <bits/stdc++.h>
using namespace std;
const int maxn = 24, mod = 1e9 + 7;
int n, m, b[2], f[1 << maxn], dis[1 << maxn];
int readn() {
  int x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ '0');
    ch = getchar();
  }
  return x;
}
int main() {
  n = readn();
  for (int i = 0; i < n; i++) dis[1 << i] = readn();
  m = readn();
  if (m > 0) b[0] = readn();
  if (m > 1) b[1] = readn();
  f[0] = 1;
  for (int i = 1; i < (1 << n); i++) {
    int j = i & -i, k = i;
    dis[i] = dis[i ^ j] + dis[j];
    if (dis[i] == b[0] || dis[i] == b[1]) continue;
    while (k) {
      j = k & -k;
      f[i] += f[i ^ j];
      if (f[i] >= mod) f[i] -= mod;
      k ^= j;
    }
  }
  printf("%d\n", f[(1 << n) - 1]);
  return 0;
}
