#include <bits/stdc++.h>
const int NS = 24, MS = 1 << 24;
const int MOD = 1000000007;
int n, k, s, t, lim;
int a[NS], b[NS];
int val[MS], dp[MS];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]), val[1 << i] = a[i];
  scanf("%d", &k);
  for (int i = 0; i < k; i++) scanf("%d", &b[i]);
  val[0] = 0, dp[0] = 1, lim = 1 << n;
  for (int i = 1; i < lim; i++) {
    t = i & (-i), dp[i] = 0;
    val[i] = val[i ^ t] + val[t];
    if (val[i] >= MOD) val[i] = MOD;
    if (val[i] == b[0] || val[i] == b[1]) continue;
    long long r = 0;
    for (int j = i; j; j -= t) t = j & (-j), r += dp[i ^ t];
    dp[i] = r % MOD;
  }
  printf("%d\n", dp[lim - 1]);
  return 0;
}
