#include <bits/stdc++.h>
using namespace std;
const int p = 1e9 + 7;
int a[1 << 24], b[10], f[1 << 24], sum[1 << 24];
int c[32];
int n, m, t;
void lowbit(int s) {
  while (s != 0) {
    int l = s & (-s);
    t++;
    c[t] = l;
    s = s ^ l;
  }
}
int id(int x) {
  int s = 0;
  while (x != 0) {
    x = x / 2;
    s++;
  }
  return s;
}
long long getans(int s) {
  long long ans = 0;
  while (s != 0) {
    int l = s & (-s);
    ans = (a[id(l)] % p + ans) % p;
    s = s - l;
  }
  for (int i = 1; i <= m; i++)
    if (b[i] == ans) return 0;
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[1 << (i - 1)]);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) scanf("%d", &b[i]);
  f[0] = 1;
  for (int i = 0; i <= (1 << n) - 1; i++) {
    t = 0;
    if (i) sum[i] = sum[i ^ (i & (-i))] + a[i & (-i)];
    sum[i] = min(sum[i], p);
    for (int j = 1; j <= m; ++j)
      if (sum[i] == b[j]) f[i] = 0;
    if (!f[i]) continue;
    for (int j = (~i) & ((1 << n) - 1); j > 0;) {
      int x = j & (-j);
      f[i ^ x] += f[i];
      f[i ^ x] %= p;
      j ^= x;
    }
  }
  cout << f[(1 << n) - 1] % p << endl;
}
