#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010 + 10;
const long long mod = 1e9 + 7;
int a[30];
int b[3];
long long dp[(1 << 24)];
int sum[(1 << 24)];
int main() {
  int n, k;
  int i, j;
  while (scanf("%d", &n) != EOF) {
    memset(dp, 0, sizeof(dp));
    memset(sum, 0, sizeof(sum));
    for (i = 0; i < n; i++) {
      scanf("%d", a + i);
      sum[(1 << i)] = a[i];
    }
    scanf("%d", &k);
    for (i = 0; i < k; i++) {
      scanf("%d", b + i);
    }
    dp[0] = 1;
    for (i = 1; i < (1 << n); i++) {
      int cnt = 0;
      int y = i;
      cnt = sum[i] = sum[y & (-y)] + sum[i - (y & (-y))];
      if (k == 2 && (cnt == b[0] || cnt == b[1])) continue;
      if (k == 1 && (cnt == b[0])) continue;
      int g = 0;
      y = i;
      while (y) {
        int p = (y) & (-y);
        y -= p;
        dp[i] += dp[y + g];
        if (dp[i] > mod) dp[i] -= mod;
        g += p;
      }
    }
    printf("%lld\n", dp[(1 << n) - 1]);
  }
}
