#include <bits/stdc++.h>
using namespace std;
const int maxM = (1 << 24) + 100;
const int maxN = 26;
const int base = 1e9 + 7;
int a[maxN], b[2], n, k, sl[maxM];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%i", &a[i]);
  for (int i = 0; i < n; i++) sl[1 << i] = a[i];
  cin >> k;
  for (int i = 0; i < k; i++) scanf("%i", &b[i]);
  sl[0] = 0;
  for (int i = 1; i < (1 << n); i++) sl[i] = sl[i & (-i)] + sl[i - (i & (-i))];
  sl[0] = 1;
  for (int i = 1; i < (1 << n); i++)
    if (sl[i] == b[0] || (k > 0 && sl[i] == b[k - 1]))
      sl[i] = 0;
    else {
      sl[i] = 0;
      for (int j = 0; j < n; j++)
        if (((i >> j) & 1) == 1) {
          sl[i] += sl[i - (1 << j)];
          if (sl[i] > base) sl[i] -= base;
        }
    }
  cout << sl[(1 << n) - 1];
  return 0;
}
