#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007LL;
long long ans = 0, a[25], b[5], f[1 << 24], cnt[1 << 24];
int n, k;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  scanf("%d", &k);
  for (int i = 1; i <= k; i++) scanf("%I64d", &b[i]);
  for (int i = 1; i < (1 << n); i++) {
    int cnt = __builtin_ctz(i);
    f[i] = f[i ^ (1 << cnt)] + a[cnt + 1];
  }
  cnt[0] = 1;
  for (int i = 1; i < (1 << n); i++) {
    for (int j = 1; j <= k; j++)
      if (f[i] == b[j]) {
        cnt[i] = -1;
        break;
      }
    if (cnt[i] == -1) {
      cnt[i] = 0;
      continue;
    }
    for (int j = 1; j <= n; j++)
      if (i & (1 << j - 1)) cnt[i] += cnt[i ^ (1 << j - 1)];
    cnt[i] %= MOD;
  }
  printf("%I64d\n", cnt[(1 << n) - 1]);
  return 0;
}
