#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int n, k;
int a[(1 << 24) + 2];
long long dp[(1 << 24) + 2];
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  long long all = 0;
  long long al;
  int bit, x;
  for (int i = 0; i < n; i++) {
    cin >> a[1 << i];
    all += a[1 << i];
  }
  set<int> st;
  cin >> k;
  for (int i = 0; i < k; i++) {
    cin >> x;
    st.insert(x);
  }
  dp[0] = !st.count(all);
  int mx = 1 << n;
  for (int i = 1; i < mx; i++) {
    x = i;
    al = all;
    while (x) {
      bit = x & (-x);
      al -= a[bit];
      x -= bit;
      dp[i] += dp[i - bit];
      if (dp[i] >= mod) dp[i] -= mod;
    }
    if (st.count(al)) dp[i] = 0;
  }
  cout << dp[(mx - 1)] << endl;
  return 0;
}
