#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int M = 100005;
int main() {
  int n;
  scanf("%d", &n);
  int a[n + 2];
  for (int i = 0; i <= n - 1; i++) scanf("%d", &a[i]);
  int N = (1LL << n) - 1;
  int k;
  cin >> k;
  int bad[2] = {-1, -1};
  for (int i = 0; i <= k - 1; i++) scanf("%d", &bad[i]);
  int dp[N + 2];
  for (int i = 0; i <= N; i++) dp[i] = 0;
  dp[0] = 1;
  for (int msk = 1; msk <= N; msk++) {
    long long sum = 0;
    for (int j = 0; (1 << j) <= msk; j++) {
      if ((1 << j) & msk) {
        sum += a[j];
        dp[msk] += dp[msk ^ (1 << j)];
        if (dp[msk] > mod) dp[msk] = dp[msk] - mod;
      }
    }
    if (sum == bad[0] || sum == bad[1]) dp[msk] = 0;
  }
  printf("%d\n", dp[N]);
  return 0;
}
