#include <bits/stdc++.h>
using namespace std;
int P[30], P1[30];
void Init() {
  P[0] = 1;
  for (int i = 1; i < 30; i++) P[i] = 1ll * P[i - 1] * i % 1000000007;
}
int n, A[30], K, K1[5], dp[1 << 24], ans, Id[(1 << 24) + 1];
long long cnt[1 << 24];
void Add(int &x, int y) {
  x += y;
  if (x >= 1000000007) x -= 1000000007;
}
int main() {
  Init();
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", &A[i]), P1[i] = (1 << i), Id[P1[i]] = i;
  P1[n] = 1 << n;
  Id[P1[n]] = n;
  scanf("%d", &K);
  for (int i = 1; i <= K; i++) scanf("%d", &K1[i]);
  for (int i = K + 1; i <= 2; i++) K1[i] = -1;
  sort(K1 + 1, K1 + K + 1);
  dp[0] = 1;
  for (int i = 0; i < P1[n]; i++) {
    if (i) cnt[i] = cnt[i - (i & -i)] + A[Id[i & -i]];
    if (cnt[i] == K1[1] || cnt[i] == K1[2]) continue;
    int x = i ^ (P1[n] - 1);
    while (x) {
      int j = x & -x;
      x -= j;
      j = Id[j];
      dp[i + P1[j]] = (dp[i + P1[j]] + dp[i]) % 1000000007;
    }
  }
  if (cnt[P1[n] - 1] == K1[1] || cnt[P1[n] - 1] == K1[2])
    puts("0");
  else
    printf("%d\n", (dp[P1[n] - 1]) % 1000000007);
  return 0;
}
