#include <bits/stdc++.h>
using namespace std;
long long dp[1 << 25], sum;
int main() {
  int n;
  cin >> n;
  int arr1[25], arr2[3];
  for (int i = 0; i < n; i++) cin >> arr1[i];
  int k;
  cin >> k;
  for (int i = 0; i < k; i++) cin >> arr2[i];
  dp[0] = 0;
  for (int i = 1; i < (1 << n); i++) {
    int pos = __builtin_ctz(i);
    dp[i] = dp[i ^ (1 << pos)] + arr1[pos];
  }
  for (int i = 1; i < (1 << n); i++) {
    for (int j = 0; j < k; j++) {
      if (dp[i] == arr2[j]) {
        dp[i] = -1;
        break;
      }
    }
  }
  dp[0] = 1;
  for (int i = 1; i < (1 << n); i++) {
    if (dp[i] < 0)
      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] %= 1000000007;
    }
  }
  cout << dp[(1 << n) - 1] << endl;
  return 0;
}
