#include <bits/stdc++.h>
using namespace std;
long long int dp[1 << 24], sum[1 << 24], ar[25];
int u[2];
int main() {
  int n;
  cin >> n;
  u[0] = -1;
  u[1] = -1;
  for (int i = 0; i <= n - 1; i++) cin >> ar[i];
  int k;
  cin >> k;
  for (int i = 0; i <= k - 1; i++) {
    cin >> u[i];
  }
  sum[0] = 0;
  dp[0] = 1;
  for (int i = 1; i < (1 << n); i++) {
    int j = __builtin_ctz(i);
    sum[i] = sum[(1 << j) ^ i] + ar[j];
  }
  for (int i = 1; i <= (1 << (n)) - 1; i++) {
    if (sum[i] == u[0] || sum[i] == u[1])
      dp[i] = 0;
    else
      for (int j = 0; j < n; j++)
        if ((1 << j) & i) dp[i] += dp[(1 << j) ^ i];
    dp[i] %= 1000000007;
  }
  cout << dp[(1 << (n)) - 1] % 1000000007;
  return 0;
}
