#include <bits/stdc++.h>
using namespace std;
const int MAXN = 24, MOD = 1e9 + 7;
int n, k, x, a[MAXN], BadPoint[2], dp[(1 << MAXN)];
int32_t main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  cin >> k;
  for (int i = 0; i < k; i++) cin >> BadPoint[i];
  dp[0] = 1;
  for (int mask = 1; mask < (1 << n); mask++) {
    int y = mask, sum = 0;
    while (y) {
      int i = __builtin_ctz(y);
      y ^= (1 << i);
      dp[mask] += dp[mask ^ (1 << i)];
      if (dp[mask] >= MOD) dp[mask] -= MOD;
      sum += a[i];
    }
    for (int i = 0; i < k; i++)
      if (sum == BadPoint[i]) dp[mask] = 0;
  }
  cout << dp[(1 << n) - 1];
}
