#include <bits/stdc++.h>
using namespace std;
int X[1 << 24], dis[1 << 24 + 1];
int card[50];
int b1, b2;
inline int lowbit(int x) { return x & -x; }
const int mod = 1000000007;
inline void update(int q) {
  for (register int i = q, j; i; i ^= j) {
    j = lowbit(i);
    X[q] += X[q ^ j];
    X[q] = (X[q] >= mod ? X[q] - mod : X[q]);
  }
}
inline int read() {
  int d = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) {
    d = d * 10 + ch - 48;
    ch = getchar();
  }
  return d;
}
int main() {
  int n;
  n = read();
  for (int i = 0; i < n; i++) dis[1 << i] = read();
  int m;
  m = read();
  if (m > 0) b1 = read();
  if (m > 1) b2 = read();
  X[0] = 1;
  for (register int i = 1; i < (1 << n); i++) {
    int j = lowbit(i);
    dis[i] = dis[i ^ j] + dis[j];
    if (dis[i] == b1) continue;
    if (dis[i] == b2) continue;
    update(i);
  }
  printf("%d\n", X[(1 << n) - 1]);
}
