#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1000000000,1000000000")
using namespace std;
const long long inf = 1e18 + 7;
const long long mod = 1e9 + 7;
const double eps = 1e-9;
const double PI = 2 * acos(0.0);
const double E = 2.71828;
int f[1 << 24], sum[1 << 24], n, k, a[24], b[2];
int main(void) {
  scanf("%d", &n);
  for (long long(i) = 0; (i) < (long long)(n); (i)++) scanf("%d", &a[i]);
  scanf("%d", &k);
  b[0] = b[1] = -1;
  for (long long(i) = 0; (i) < (long long)(k); (i)++) scanf("%d", &b[i]);
  f[0] = 1;
  for (long long(i) = 0; (i) < (long long)(1 << n); (i)++) {
    if (i) sum[i] = sum[i & (i - 1)] + a[__builtin_ctz(i)];
    if (sum[i] == b[0] || sum[i] == b[1]) continue;
    for (long long j = i; j; j &= j - 1) {
      f[i] += f[i ^ (j & -j)];
      if (f[i] >= mod) f[i] -= mod;
    }
  }
  printf("%d\n", f[(1 << n) - 1]);
  return 0;
}
