#include <bits/stdc++.h>
using namespace std;
int lowbit(int x) { return x & (-x); }
const int mod = 1000000007;
bool vis[1 << 24];
int b[30];
int c[10];
int e[1 << 24];
int dp[1 << 24];
int n;
int main(void) {
  int k;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &b[i]);
  }
  scanf("%d", &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d", &c[i]);
  }
  for (int i = 0; i < n; i++) {
    e[1 << i] = b[i];
  }
  dp[0] = 1;
  for (int i = 1; i < (1 << n); i++) {
    int tmp = 0;
    int tx = i;
    while (tx != 0) {
      tmp += e[lowbit(tx)];
      tx ^= lowbit(tx);
    }
    int flag = 1;
    for (int j = 1; j <= k; j++) {
      if (tmp == c[j]) {
        flag = 0;
      }
    }
    if (flag) {
      tmp = i;
      while (tmp != 0) {
        dp[i] = (dp[i] + dp[i - lowbit(tmp)]) % mod;
        tmp ^= lowbit(tmp);
      }
    } else {
      dp[i] = 0;
    }
  }
  printf("%d\n", dp[(1 << n) - 1]);
  return 0;
}
