#include <bits/stdc++.h>
using namespace std;
const int MAX = 400;
const int Mod = (int)1e9 + 7;
const int NUM = 4;
int n, k;
int a[MAX], c[MAX];
int f[1 << 24];
int main() {
  int i, j;
  scanf("%d", &n);
  for ((i) = (0); (i) != (n); ++(i)) scanf("%d", &a[i]);
  scanf("%d", &k);
  for ((i) = (0); (i) != (k); ++(i)) scanf("%d", &c[i]);
  sort(c, c + k);
  f[0] = 1;
  for ((i) = (1); (i) != ((1 << n)); ++(i)) {
    int& np = f[i];
    int sum = 0;
    for ((j) = (0); (j) != (n); ++(j))
      if ((i >> j) & 1) {
        sum += a[j];
        np = np + f[i & (~(1 << j))];
        if (np >= Mod) np -= Mod;
      }
    for ((j) = (0); (j) != (2); ++(j))
      if (sum == c[j]) np = 0;
  }
  cout << f[(1 << n) - 1] << endl;
  return 0;
}
