#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7, N = (1 << 24) + 1;
int n, m, k[3];
long long f[N], sum[N];
inline int lowbit(int x) { return x & (-x); }
int main() {
  scanf("%d", &n);
  int nn = (1 << n) - 1;
  f[0] = 1;
  for (register int i = 0; i < n; ++i) scanf("%lld", &sum[1 << i]);
  scanf("%d", &m);
  for (register int i = 1; i <= m; ++i) scanf("%d", &k[i]);
  for (register int i = 1; i <= nn; ++i) {
    sum[i] = sum[i ^ lowbit(i)] + sum[lowbit(i)];
    if (sum[i] == k[1] || sum[i] == k[2]) continue;
    for (register int j = i; j; j -= lowbit(j)) {
      f[i] += f[i ^ lowbit(j)];
      if (f[i] >= mod) f[i] -= mod;
    }
  }
  printf("%lld", f[nn]);
  return 0;
}
