#include <bits/stdc++.h>
using namespace std;
int dp[(1 << 24) + 10], sum[(1 << 24) + 10];
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  int m;
  scanf("%d", &m);
  vector<int> b(m);
  for (int i = 0; i < m; i++) scanf("%d", &b[i]);
  dp[0] = 1;
  sum[0] = 0;
  for (int mask = 0; mask < (1 << n); mask++) {
    for (int i = 0; i < n; i++)
      if (mask & (1 << i)) {
        sum[mask] = min(sum[mask ^ (1 << i)] + a[i], 1000000007);
        break;
      }
    bool ok = true;
    for (int i = 0; i < m; i++)
      if (b[i] == sum[mask]) {
        ok = false;
        break;
      }
    if (!ok) {
      dp[mask] = 0;
      continue;
    }
    for (int i = 0; i < n; i++)
      if (!(mask & (1 << i))) {
        int new_mask = (mask ^ (1 << i));
        dp[new_mask] += dp[mask];
        if (dp[new_mask] >= 1000000007) dp[new_mask] -= 1000000007;
      }
  }
  cout << dp[(1 << n) - 1] << endl;
  return 0;
}
