#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[30], ob[5];
long long f[1 << 24], sum[1 << 24];
bool ok(int x) {
  for (int i = 1; i <= k; i++)
    if (x == ob[i]) return false;
  return true;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  int tot = (1 << n);
  for (int i = 0; i < tot; i++) {
    int j = __builtin_ctz(i);
    sum[i] = sum[i ^ (1 << j)] + a[j];
  }
  cin >> k;
  for (int i = 1; i <= k; i++) cin >> ob[i];
  f[0] = 1;
  for (int i = 1; i < tot; i++) {
    if (!ok(sum[i])) continue;
    f[i] = 0;
    for (int j = 0; j < n; j++)
      if (i & (1 << j)) f[i] += f[i ^ (1 << j)];
    f[i] %= 1000000007;
  }
  cout << f[tot - 1] << endl;
  return 0;
}
