#include <bits/stdc++.h>
using namespace std;
char buf[1 << 15], *fs, *ft;
inline char getc() {
  return (fs == ft &&
          (ft = (fs = buf) + fread(buf, 1, 1 << 15, stdin), fs == ft))
             ? 0
             : *fs++;
}
inline int read() {
  register int x = 0, f = 1;
  char ch = getc();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getc();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getc();
  }
  return x * f;
}
inline void put(register int x) {
  x < 0 ? putchar('-'), x = -x : 0;
  register int num = 0;
  char ch[50];
  while (x) ch[++num] = x % 10 + '0', x /= 10;
  num == 0 ? putchar('0') : 0;
  while (num) putchar(ch[num--]);
  putchar('\n');
  return;
}
const int MAXN = 24;
int f[1 << MAXN];
int n, m;
int a[MAXN + 6];
long long b[3], pos[1 << MAXN];
int main() {
  n = read();
  f[0] = 1;
  for (register int i = 1; i <= n; ++i) pos[1 << (i - 1)] = read();
  m = read();
  if (m > 0) b[1] = read();
  if (m > 1) b[2] = read();
  for (register int i = 1; i <= (1 << n) - 1; ++i) {
    register int k = i & (-i);
    pos[i] = pos[i - k] + pos[k];
    if (pos[i] == b[1] || pos[i] == b[2]) continue;
    for (register int s = i; s; s -= s & (-s)) {
      f[i] = f[i] + f[i ^ (s & (-s))];
      if (f[i] > 1000000007) f[i] -= 1000000007;
    }
  }
  put(f[(1 << n) - 1]);
  return 0;
}
