#include <bits/stdc++.h>
using namespace std;
int n;
int a[24], b[2];
long long f[1 << 24], s[1 << 24];
void Init() {
  scanf("%d", &n);
  ;
  int nn = 1 << n;
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  ;
  s[0] = 0;
  for (int i = 0; i < nn; i++) {
    int j = __builtin_ctz(i);
    s[i] = s[i - (1 << j)] + a[j];
  }
  int m;
  scanf("%d", &m);
  ;
  for (int i = 0; i < m; i++) scanf("%d", &b[i]);
  ;
  memset(f, 0, sizeof(f));
  ;
  f[0] = 1;
  for (int i = 0; i < nn; i++) {
    for (int j = 0; j < m; j++)
      if (s[i] == (long long)b[j]) f[i] = 0;
    f[i] %= 1000000007;
    for (int j = 0; j < n; j++) {
      if ((i & (1 << j)) == 0) (f[i + (1 << j)] += f[i]);
    }
  }
  cout << f[nn - 1];
}
int main() {
  Init();
  return 0;
}
