#include <bits/stdc++.h>
using namespace std;
const int M = 1 << 24;
int dp[M];
int n, k;
int a[25], bad[2], nodes[25];
int main() {
  memset(bad, -1, sizeof bad);
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  scanf("%d", &k);
  for (int i = 0; i < k; i++) scanf("%d", &bad[i]);
  dp[0] = 1;
  for (int i = 0; i < 1 << n; i++) {
    int c = 0, alt = i, len = 0;
    long long int sum = 0;
    while (alt) {
      if (alt & 1) nodes[len++] = c, sum += a[c];
      alt >>= 1;
      c++;
    }
    for (int l = 0; l < len; l++) {
      int j = nodes[l];
      int mask = 1 << j;
      if ((i | mask) == i) {
        if (sum == bad[0] || sum == bad[1]) continue;
        int x = dp[i];
        x = (x + dp[i ^ mask]);
        if (x >= 1000000007) x -= 1000000007;
        dp[i] = x;
      }
    }
  }
  cout << dp[(1 << n) - 1];
  return 0;
}
