#include <bits/stdc++.h>
using namespace std;
int n, m, a[24 + 10], u[3], sum[(1 << 24) + 10], dp[(1 << 24) + 10];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum[1 << i] = a[i];
  }
  cin >> m;
  for (int i = 1; i <= m; i++) cin >> u[i];
  dp[0] = 1;
  for (int i = 0; i < (1 << n); i++) {
    sum[i] = sum[i & ~(i & (-i))] + sum[(i & (-i))];
    if (sum[i] == u[1] || sum[i] == u[2]) continue;
    for (int j = i; j; j -= (j & (-j)))
      dp[i] = (dp[i] + dp[i & ~(j & (-j))]) % 1000000007;
  }
  cout << dp[(1 << n) - 1] << endl;
  return 0;
}
