#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
const int N = 1 << 24;
int dp[N] = {0};
long long s[N] = {0};
const int M = 1e9 + 7;
inline void add(int &a, int b) {
  a += b;
  if (a >= M) a -= M;
}
int32_t main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; ++i) cin >> a[i];
  int k;
  cin >> k;
  if (k == 0) {
    const int M = 1e9 + 7;
    int ans = 1;
    for (int i = 1; i <= n; ++i) {
      ans = (1ll * ans * i) % M;
    }
    cout << ans << '\n';
    return 0;
  }
  int ban[3] = {0};
  for (int i = 0; i < k; ++i) cin >> ban[i];
  dp[0] = 1;
  int pw = (1 << n);
  for (int m = 0; m < pw; ++m) {
    for (int i = 0; i < n; ++i) {
      if ((m >> i) & 1) {
        s[m] = a[i] + s[m ^ (1 << i)];
        break;
      }
    }
    bool bad = (s[m] == ban[0] || s[m] == ban[1]);
    if (!bad) {
      for (int i = 0; i < n; ++i) {
        if ((m >> i) & 1) add(dp[m], dp[m ^ (1 << i)]);
      }
    }
  }
  cout << dp[(1 << n) - 1];
}
