#include <bits/stdc++.h>
using namespace std;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);
template <class T>
int chmin(T &t, T f) {
  return (t > f) ? (t = f, 1) : 0;
}
template <class T>
int chmax(T &t, T f) {
  return (t < f) ? (t = f, 1) : 0;
}
inline int getint() {
  int a;
  return scanf("%d", &a) ? a : (fprintf(stderr, "trying to read\n"), -1);
}
inline double getdouble() {
  double a;
  return scanf("%lf", &a) ? a : (fprintf(stderr, "trying to read\n"), -1);
}
const int N = 24;
long long a[N], s[1 << N], b[2], ways[1 << N];
void myCode() {
  int n = getint();
  for (int i = (int)0; i < (int)n; i++) a[i] = getint();
  int bad = getint();
  for (int i = (int)0; i < (int)bad; i++) b[i] = getint();
  s[0] = 0;
  for (int i = (int)1; i < (int)1 << n; i++) {
    int first = __builtin_ctz(i);
    s[i] = s[i - (1 << first)] + a[first];
  }
  ways[0] = 1;
  for (int j = (int)0; j < (int)bad; j++)
    if (b[j] == 0) ways[0] = 0;
  for (int i = (int)1; i < (int)1 << n; i++) {
    for (int j = (int)0; j < (int)bad; j++)
      if (s[i] == b[j]) goto nah;
    for (int first = i; first > 0; first &= first - 1) {
      int sub = i - (first & -first);
      ways[i] += ways[sub];
    }
    ways[i] %= INF;
  nah:
    continue;
  }
  cout << ways[(1 << n) - 1] << endl;
}
int main() {
  myCode();
  return 0;
}
