#include <bits/stdc++.h>
using namespace std;
int N, M, K;
long long dp[(1 << 24)], sum[(1 << 24)];
int st[25], No[25], two[25], mx;
int main() {
  int i, j, to, cnt, tmp;
  long long get;
  scanf("%d", &N);
  for (i = 1; i <= N; i++) scanf("%d", &st[i]), sum[1 << i - 1] = st[i];
  scanf("%d", &K);
  for (i = 1; i <= K; i++) scanf("%d", &No[i]);
  for (i = two[0] = 1; i <= N; i++) two[i] = (two[i - 1] << 1);
  to = (1 << N), dp[0] = 1;
  for (i = 1; i <= to - 1; i++) sum[i] = sum[i & (i - 1)] + sum[i & (-i)];
  for (i = 1; i <= to - 1; i++) {
    if (sum[i] != No[1] && sum[i] != No[2])
      for (j = 1; j <= N; j++)
        if ((i >> j - 1) & 1) dp[i] += dp[i ^ two[j - 1]];
    dp[i] %= 1000000007;
  }
  printf("%I64d\n", dp[to - 1] % 1000000007);
  return 0;
}
