#include <bits/stdc++.h>
int n;
long long a[25], ssum[16777300];
long long dp[16777300] = {0};
long long mod = 1000000007;
inline int lowbit(int x) { return x & (-x); }
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    ssum[1 << i] = a[i];
  }
  int k;
  scanf("%d", &k);
  long long b[k];
  for (int i = 0; i < k; i++) scanf("%lld", &b[i]);
  dp[0] = 1;
  ssum[0] = 0;
  int Maxs = (1 << n) - 1;
  for (int i = 1, lb; i <= Maxs; i++) {
    lb = lowbit(i);
    ssum[i] = ssum[i ^ lb] + ssum[lb];
  }
  for (int i = 0, ts, lb; i <= Maxs; i++) {
    if (k == 1 && ssum[i] == b[0])
      continue;
    else if (k == 2 && (ssum[i] == b[0] || ssum[i] == b[1]))
      continue;
    ts = i;
    while (ts) {
      lb = lowbit(ts);
      dp[i] += dp[i ^ lb];
      if (dp[i] >= mod) dp[i] -= mod;
      ts -= lb;
    }
  }
  printf("%lld", dp[Maxs]);
  return 0;
}
