#include <bits/stdc++.h>
inline int read() {
  int d = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) {
    d = d * 10 + ch - 48;
    ch = getchar();
  }
  return d;
}
int n, m, mx;
int dis[1 << 24], a[2];
int f[1 << 24];
int main() {
  n = read();
  for (register int i = 0; i < n; ++i) dis[1 << i] = read();
  m = read();
  for (register int i = 0; i < m; ++i) a[i] = read();
  f[0] = 1, mx = (1 << n) - 1;
  for (register int i = 1; i <= mx; ++i) {
    dis[i] = dis[i ^ ((i) & (-i))] + dis[((i) & (-i))];
    if (dis[i] == a[0] || dis[i] == a[1]) continue;
    for (register int j = i, k = ((j) & (-j)); j; j ^= k, k = ((j) & (-j))) {
      f[i] += f[i ^ k];
      if (f[i] > 1000000007) f[i] -= 1000000007;
    }
  }
  printf("%d", f[mx]);
  return 0;
}
