#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int a[25], b[25];
int dp[1 << 24];
int main() {
  int n, k;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  scanf("%d", &k);
  for (int i = 1; i <= k; i++) scanf("%d", &b[i]);
  dp[0] = 1;
  for (int i = 1; i < (1 << n); i++) {
    int sum = 0, ans = 0;
    for (int j = 0; j < n; j++) {
      if ((i >> j) & 1) {
        sum += a[j];
        ans = (ans + dp[i ^ (1 << j)]) % mod;
        if (sum > 1e9) sum = 1e9 + 1;
      }
    }
    bool ok = 1;
    for (int j = 1; j <= k; j++) {
      if (sum == b[j]) ok = 0;
    }
    if (!ok) continue;
    dp[i] = (dp[i] + ans) % mod;
  }
  printf("%d\n", dp[(1 << n) - 1]);
}
