#include <bits/stdc++.h>
using namespace std;
int a[32], bad[4], dp[1 << 24], n, k;
int main() {
  while (cin >> n) {
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    fill(bad, bad + 2, -1);
    cin >> k;
    for (int i = 0; i < k; i++) {
      cin >> bad[i];
    }
    dp[(1 << n) - 1] = 1;
    if (accumulate(a, a + n, 0) == bad[0] ||
        accumulate(a, a + n, 0) == bad[1]) {
      dp[(1 << n) - 1] = 0;
    }
    for (int mask = (1 << n) - 2; mask >= 0; mask--) {
      int sum = 0;
      int ret = 0;
      for (int i = 0; i < n; i++) {
        if ((mask >> i) & 1) {
          sum += a[i];
          if (sum >= 1000000007) {
            sum = 1000000007;
          }
        } else {
          ret += dp[mask | (1 << i)];
          if (ret >= 1000000007) ret -= 1000000007;
        }
      }
      if (sum == bad[0] || sum == bad[1]) {
        ret = 0;
      }
      dp[mask] = ret;
    }
    cout << dp[0] << endl;
  }
  return 0;
}
