#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 24;
const int NBITS = 1 << MAX_N;
const int MOD = 1000000007;
int as[MAX_N], bnums[NBITS];
long long ass[NBITS];
int dp[NBITS];
inline void addmod(int &a, int b) { a = (a + b) % MOD; }
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", as + i);
  int nbits = 1 << n;
  ass[0] = 0, bnums[0] = 0;
  for (int bits = 1, msb = 1, msi = 0; bits < nbits; bits++) {
    if ((msb << 1) <= bits) msb <<= 1, msi++;
    bnums[bits] = bnums[bits ^ msb] + 1;
    ass[bits] = ass[bits ^ msb] + as[msi];
  }
  int k, bd0 = -1, bd1 = -1;
  scanf("%d", &k);
  if (k == 1)
    scanf("%d", &bd0);
  else if (k == 2)
    scanf("%d%d", &bd0, &bd1);
  dp[0] = 1;
  for (int bits = 0; bits < nbits; bits++)
    if (ass[bits] != bd0 && ass[bits] != bd1)
      for (int j = 0, bj = 1; j < n; j++, bj <<= 1)
        if (!(bits & bj)) addmod(dp[bits | bj], dp[bits]);
  int nmsk = nbits - 1;
  int ans = (ass[nmsk] != bd0 && ass[nmsk] != bd1) ? dp[nmsk] : 0;
  printf("%d\n", ans);
  return 0;
}
