#include <bits/stdc++.h>
using namespace std;
const int maxn = 24, mod = 1e9 + 7;
int n, a[1 << maxn], f[1 << maxn], sum[1 << maxn];
int m, b[2];
inline int lowbit(int x) { return x & -x; }
signed main() {
  b[0] = b[1] = -1;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[1 << i];
  cin >> m;
  for (int i = 0; i < m; i++) cin >> b[i];
  f[0] = 1;
  for (register int i = 1; i < (1 << n); i++) {
    sum[i] = sum[i ^ lowbit(i)] + a[lowbit(i)];
    if (sum[i] == b[0] || sum[i] == b[1]) continue;
    int x = i;
    for (int j = lowbit(x); j != 0; x -= j, j = lowbit(x)) {
      f[i] += f[i ^ j];
      f[i] = f[i] >= mod ? f[i] - mod : f[i];
    }
  }
  cout << f[(1 << n) - 1];
  return 0;
}
