#include <bits/stdc++.h>
using namespace std;
int n, k, a[16777216], b[3], base[30], f[16777216];
inline int lowbit(int x) { return (x) & (-x); }
int main() {
  base[1] = 1;
  for (int i = 2; i <= 25; ++i) base[i] = base[i - 1] << 1;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  cin >> k;
  for (int i = 1; i <= k; ++i) cin >> b[i];
  f[0] = 1;
  for (int i = 1; i < base[n + 1]; ++i) {
    int t = 0;
    for (int j = 1; j <= n; ++j)
      if (i & base[j]) f[i] += f[i ^ base[j]], f[i] %= 1000000007, t += a[j];
    if (t == b[1] || t == b[2]) f[i] = 0;
  }
  cout << f[base[n + 1] - 1] << endl;
  return 0;
}
