#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 25;
int n, m;
int a[maxn], b[maxn], f[1 << maxn], sum[1 << maxn];
inline bool cmp(int x, int y) { return x > y; }
int main() {
  scanf("%d", &n);
  for (register int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1, cmp);
  for (register int i = 1; i <= n; i++) sum[1 << (i - 1)] = a[i];
  scanf("%d", &m);
  for (register int j = 1; j <= m; j++) scanf("%d", &b[j]);
  f[0] = 1;
  for (register int i = 1; i < (1 << n); i++) {
    sum[i] = sum[i ^ (i & -i)] + sum[(i & -i)];
    if (sum[i] == b[1] || sum[i] == b[2]) continue;
    for (register int j = i; j; j -= (j & -j))
      f[i] = (f[i] + f[i ^ (j & -j)]) % mod;
  }
  printf("%d", f[(1 << n) - 1] % mod);
  return 0;
}
