#include <bits/stdc++.h>
using namespace std;
template <class _T>
inline void read(_T &_x) {
  int _t;
  bool _flag = false;
  while ((_t = getchar()) != '-' && (_t < '0' || _t > '9'))
    ;
  if (_t == '-') _flag = true, _t = getchar();
  _x = _t - '0';
  while ((_t = getchar()) >= '0' && _t <= '9') _x = _x * 10 + _t - '0';
  if (_flag) _x = -_x;
}
const int maxn = 24;
const int maxv = (1 << maxn) + 1;
const int mod = 1e9 + 7;
int n, k;
int a[maxv], b[2], sum[maxv];
long long f[maxv];
int main() {
  read(n);
  for (int i = 0; i < n; ++i) read(a[1 << i]);
  read(k);
  for (int i = 0; i < k; ++i) read(b[i]);
  f[0] = 1;
  for (register int i = 1, tmp; i < (1 << n); ++i) {
    tmp = (i & -i);
    sum[i] = sum[i ^ tmp] + a[tmp];
    for (int j = 0; j < k; ++j)
      if (sum[i] == b[j]) goto end;
    for (register int st = i; st; st ^= tmp, tmp = (st & -st))
      f[i] += f[i ^ tmp];
    f[i] %= mod;
  end:;
  }
  cout << f[(1 << n) - 1] << endl;
  return 0;
}
