#include <bits/stdc++.h>
using namespace std;
const int N = (1 << 24) + 10, mod = 1e9 + 7;
int a[25], p[3], dp[N], n, k, t;
long long sum;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  cin >> k;
  for (int i = 0; i < k; i++) cin >> p[i];
  dp[0] = 1;
  for (int msk = 1; msk < (1 << n); msk++) {
    sum = 0;
    for (int i = 0; i < n; i++)
      if (msk & (1 << i))
        dp[msk] = (dp[msk ^ (1 << i)] + dp[msk]) % mod, sum += a[i];
    for (int i = 0; i < k; i++)
      if (sum == p[i]) dp[msk] = 0;
  }
  cout << dp[(1 << n) - 1];
  return 0;
}
