#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const double eps = 1e-8;
int n, k, m, t;
int a[30], b[4];
int dp[16800000];
int gt[16800000];
queue<int> q;
int main() {
  int i, j, x, y, z, w, u, r, size, Now, tm, Lim;
  long long v;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  scanf("%d", &k);
  for (i = 1; i <= k; i++) scanf("%d", &b[i]);
  dp[0] = 1;
  Lim = (1 << n) - 1;
  for (i = 1; i <= Lim; i++) {
    gt[i] = gt[i - (i & -i)] + a[(int)(log2(i & -i) + eps) + 1];
    if (gt[i] != b[1] && gt[i] != b[2]) {
      j = i;
      while (j != 0) {
        dp[i] += dp[i - (j & -j)];
        if (dp[i] > MOD) dp[i] %= MOD;
        j -= j & -j;
      }
    }
  }
  cout << dp[Lim];
  return 0;
}
