#include <bits/stdc++.h>
using namespace std;
int N, K, ka[3], cam[25], dp[(1 << 24)], suma, x, res;
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%d", &cam[i]);
  scanf("%d", &K);
  for (int i = 0; i < K; i++) scanf("%d", &ka[i]);
  dp[0] = 1;
  for (int i = 1; i < (1 << N); i++) {
    suma = 0;
    res = 0;
    for (int j = 0; j < N; j++)
      if (i & (1 << j)) {
        res += dp[i ^ (1 << j)];
        if (res >= 1000000007) res -= 1000000007;
        suma += cam[j];
      }
    for (int j = 0; j < K; j++)
      if (suma == ka[j]) res = 0;
    dp[i] = res;
  }
  printf("%d", dp[(1 << N) - 1]);
  return 0;
}
