#include <bits/stdc++.h>
const int maxk = 1 << 25, mod = 1000000007;
int i, j, k, m, n, c1, c2;
int sum[maxk], b[3], f[maxk];
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &sum[1 << (i - 1)]);
  scanf("%d", &m);
  b[1] = b[2] = -1;
  for (i = 1; i <= m; i++) scanf("%d", &b[i]);
  k = (1 << n) - 1, f[0] = 1;
  for (i = 1; i <= k; i++) {
    int tmp = i, lb = i & -i;
    sum[i] = sum[i - lb] + sum[lb];
    if (sum[i] == b[1] || sum[i] == b[2]) continue;
    while (tmp) {
      int j = tmp & -tmp;
      f[i] += f[i - j];
      if (f[i] >= mod) f[i] -= mod;
      tmp -= j;
    }
  }
  printf("%d\n", f[k]);
  return 0;
}
