#include <bits/stdc++.h>
using namespace std;
const int maxn = (1 << 24);
const int mod = 1e9 + 7;
int dp[maxn];
long long dist[maxn];
long long bad[2];
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<long long> v(n);
  long long sum = 0;
  for (long long &a : v) {
    cin >> a;
    sum += a;
  }
  int k;
  cin >> k;
  bad[0] = -1;
  bad[1] = -1;
  for (int i = 0; i < k; i++) {
    long long a;
    cin >> a;
    bad[i] = a;
  }
  int m = (1 << n);
  dp[0] = 1;
  for (int i = 0; i < m; i++) {
    if (dist[i] == bad[0] || dist[i] == bad[1]) {
      dp[i] = 0;
    }
    bool flag = true;
    for (int j = 0; j < n; j++) {
      if (((1 << j) & i) == 0) {
        int k = (i | (1 << j));
        dp[k] += dp[i];
        if (dp[k] >= mod) {
          dp[k] %= mod;
        }
        if (flag) {
          dist[(i | (1 << j))] = dist[i] + v[j];
        }
      } else {
        flag = false;
      }
    }
  }
  if (sum == bad[0] || sum == bad[1]) {
    cout << "0\n";
  } else {
    cout << (dp[m - 1] + mod) % mod << "\n";
  }
}
