#include <bits/stdc++.h>
const int mod = (int)1e9 + 7;
int s[(1 << 24) + 7];
int f[(1 << 24) + 7];
int n, q;
int b[24];
void init(void) {
  scanf("%d", &n);
  int t;
  for (int i = 0; i < (n); i = i + 1) {
    scanf("%d", &t);
    s[(1 << i)] = t;
  }
  scanf("%d", &q);
  for (int i = 0; i < (q); i = i + 1) scanf("%d", &b[i]);
}
void optimize(void) {
  int t;
  bool ok;
  f[0] = 1;
  s[0] = 0;
  for (int i = (1); i <= ((1 << n) - 1); i = i + 1) {
    t = i & (-i);
    s[i] = s[i ^ t] + s[t];
    if (s[i] > mod) s[i] = mod;
    f[i] = 0;
    ok = true;
    for (int j = 0; j < (q); j = j + 1)
      if (s[i] == b[j]) {
        ok = false;
        break;
      }
    if (ok)
      for (int j = 0; j < (n); j = j + 1)
        if ((i | (1 << j)) == i) {
          f[i] += f[i ^ (1 << j)];
          if (f[i] >= mod) f[i] -= mod;
        }
  }
  printf("%d", f[(1 << n) - 1]);
}
int main(void) {
  init();
  optimize();
  return 0;
}
