#include <bits/stdc++.h>
const int pi = acos(-1);
using namespace std;
const long long M = 1000000007;
int n, k, a[24], b[2];
long long dp[(1 << 24) + 1];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  cin >> k;
  for (int i = 0; i < k; i++) cin >> b[i];
  for (int i = 1; i < (1 << n); ++i) {
    int j = __builtin_ctz(i);
    dp[i] = dp[i ^ (1 << j)] + a[j];
  }
  for (int i = 0; i < (1 << n); ++i) {
    for (int j = 0; j < k; ++j) {
      if (dp[i] == b[j]) {
        dp[i] = -1;
        break;
      }
    }
  }
  dp[0] = 1;
  for (int i = 1; i < (1 << n); i++) {
    if (dp[i] == -1)
      dp[i] = 0;
    else {
      dp[i] = 0;
      for (int j = 0; j < n; j++)
        if (i & (1 << j)) dp[i] += dp[i ^ (1 << j)];
      dp[i] %= M;
    }
  }
  cout << dp[(1 << n) - 1];
  return 0;
}
