#include <bits/stdc++.h>
using namespace std;
const int N = 24;
const int inf = (int)1e9 + 1;
const long long big = (long long)1e18 + 1;
const int P = 239;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;
long long a[N];
long long sum[1 << N];
bool ok[1 << N];
int dp[1 << N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.precision(20);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  int k;
  cin >> k;
  long long bad[k];
  for (int i = 0; i < k; i++) cin >> bad[i];
  for (int i = 0; i < n; i++) sum[1 << i] = a[i];
  for (int mask = 1; mask < (1 << n); mask++)
    sum[mask] = sum[(mask - 1) & mask] + sum[mask ^ ((mask - 1) & mask)];
  for (int mask = 0; mask < (1 << n); mask++) {
    ok[mask] = true;
    for (int j = 0; j < k; j++)
      if (sum[mask] == bad[j]) ok[mask] = false;
  }
  dp[0] = 1;
  for (int mask = 0; mask < (1 << n); mask++)
    for (int i = 0; i < n; i++)
      if (!((mask >> i) & 1) && ok[mask | (1 << i)]) {
        dp[mask | (1 << i)] += dp[mask];
        if (dp[mask | (1 << i)] >= MOD) dp[mask | (1 << i)] -= MOD;
      }
  cout << dp[(1 << n) - 1] << "\n";
  return 0;
}
