#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int a = 0, f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) a = (a << 3) + (a << 1) + ch - '0';
  return a * f;
}
void write(int x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) write(x / 10);
  putchar((x % 10) ^ 48);
}
inline void writen(int x) {
  write(x);
  puts("");
}
const int mod = 1e9 + 7;
const int N = (1 << 25);
int lowbit(int x) { return x & -x; }
int sum[N], a[25], no[3], f[N], n, k;
int main() {
  n = read();
  for (int i = 0; i < n; i++) sum[1 << i] = a[i] = read();
  k = read();
  for (int i = 0; i < k; i++) no[i] = read();
  f[0] = 1;
  for (int i = 1; i < (1 << n); i++) {
    sum[i] = sum[i & ~lowbit(i)] + sum[lowbit(i)];
    if (sum[i] == no[0] || sum[i] == no[1]) continue;
    for (int j = i; j != 0; j -= lowbit(j))
      f[i] = (f[i] + f[i & ~lowbit(j)]) % mod;
  }
  writen(f[(1 << n) - 1]);
}
