#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int n, m;
int a[31];
int d[4];
int f[1 << 24];
int dis[1 << 24];
void init() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) dis[1 << i] = a[i];
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) scanf("%d", &d[i]);
  return;
}
int main() {
  init();
  f[0] = 1;
  int l = (1 << n) - 1;
  for (int i = 1; i <= l; i++) {
    int lowbit = i & -i;
    dis[i] = dis[i ^ lowbit] + dis[lowbit];
    bool c = false;
    for (int j = 1; j <= m; j++)
      if (dis[i] == d[j]) c = true;
    if (c) continue;
    int k = i;
    while (k) {
      int s = k & -k;
      k ^= s;
      f[i] += f[i ^ s];
      f[i] %= mod;
    }
  }
  printf("%d\n", f[(1 << n) - 1]);
  return 0;
}
