#include <bits/stdc++.h>
int f[1 << 24], sum[1 << 24], arr[30], krr[5];
int main() {
  int n, k, temp;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    sum[1 << i] = arr[i];
  }
  scanf("%d", &k);
  for (int i = 0; i < k; i++) scanf("%d", &krr[i]);
  f[0] = 1;
  for (int i = 1; i < (1 << n); i++) {
    sum[i] = sum[((i) & (-i))] + sum[i - ((i) & (-i))];
    if (sum[i] == krr[0] || sum[i] == krr[1])
      ;
    else {
      int idx = i;
      while (idx) {
        f[i] = (f[i] + f[i - ((idx) & (-idx))]) % 1000000007;
        idx = idx - ((idx) & (-idx));
      }
    }
  }
  printf("%d\n", f[(1 << n) - 1]);
  return 0;
}
