#include <bits/stdc++.h>
using namespace std;
int lim, n, a[33], k, b[12];
int d[(1 << 24) + 10];
long long sum[(1 << 24) + 10];
const int inf = 1000000007;
void dp() {
  d[0] = 1;
  for (int i = 0; i < n; ++i) sum[1 << i] = a[i];
  for (int i = 1; i < lim; ++i) {
    sum[i] = sum[i & (i - 1)] + sum[i ^ (i & (i - 1))];
    if (k > 0 && sum[i] == b[0]) continue;
    if (k > 1 && sum[i] == b[1]) continue;
    for (int j = 0; j < n; ++j)
      if ((i >> j) & 1) {
        d[i] += d[i ^ (1 << j)];
        if (d[i] >= inf) d[i] -= inf;
      }
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  cin >> k;
  for (int i = 0; i < k; ++i) cin >> b[i];
  lim = (1 << n);
  dp();
  cout << d[lim - 1] << endl;
  return 0;
}
