#include <bits/stdc++.h>
using namespace std;
int n, m, a[26], b[3];
long long dp[17000000], t;
int main() {
  int i, x, p, sum, need;
  while (~scanf("%d", &n)) {
    for (i = 1; i <= n; i++) scanf("%d", &a[i]);
    scanf("%d", &m);
    for (i = 1; i <= m; i++) scanf("%d", &b[i]);
    dp[0] = 1;
    need = (1 << n) - 1;
    for (x = 1; x <= need; x++) {
      p = x;
      t = sum = i = 0;
      while (p) {
        if (p % 2) {
          t += dp[x & (~(1 << i))];
          sum += a[i + 1];
        }
        i++, p >>= 1;
      }
      for (i = 1; i <= m; i++)
        if (sum == b[i]) t = 0;
      dp[x] = t % 1000000007;
    }
    printf("%I64d\n", dp[need]);
  }
  return 0;
}
