#include <bits/stdc++.h>
using namespace std;
const int md = 1000000007;
int n, m, dp[1 << 24], a[24], x, y;
int main() {
  while (~scanf("%d", &n)) {
    for (int i = 0; i < n; i++) scanf("%d", a + i);
    scanf("%d", &m);
    x = y = -1;
    if (m) scanf("%d", &x);
    if (m > 1) scanf("%d", &y);
    memset(dp, 0, sizeof dp);
    dp[0] = 1;
    for (int i = 1, ed = 1 << n; i < ed; i++) {
      long long cnt = 0;
      for (int j = 0; j < n; j++)
        if ((i >> j) & 1) {
          cnt += a[j];
          if ((dp[i] += dp[i ^ (1 << j)]) >= md) dp[i] -= md;
        }
      if (cnt == x || cnt == y) dp[i] = 0;
    }
    printf("%d\n", dp[(1 << n) - 1]);
  }
  return 0;
}
