#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
const long long N = 24, MOD = 1e9 + 7;
long long dp[(1 << N) + 1];
long long sum[(1 << N) + 1];
long long n;
long long a[N + 1];
long long k;
long long b[N + 1];
inline long long lowbit(long long x) { return x & (-x); }
void print(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
  return;
}
int main(void) {
  scanf("%I64d", &n);
  for (register long long i = 0; i < n; ++i) {
    scanf("%I64d", &a[i]);
    sum[(1 << i)] = a[i];
  }
  scanf("%I64d", &k);
  for (register long long i = 1; i <= k; ++i) {
    scanf("%I64d", &b[i]);
  }
  dp[0] = 1;
  long long maxx = (1 << n) - 1;
  for (register long long i = 1; i <= maxx; ++i) {
    sum[i] = sum[i & ~lowbit(i)] + sum[lowbit(i)];
    if (sum[i] == b[1] || sum[i] == b[2]) {
      continue;
    }
    for (register long long j = i; j; j -= lowbit(j)) {
      dp[i] += +dp[i & ~lowbit(j)];
      if (dp[i] >= MOD) dp[i] -= MOD;
    }
  End:;
  }
  print(dp[(1 << n) - 1]);
  return 0;
}
