#include <bits/stdc++.h>
#pragma GCC optimize(7)
int n, k, x = -1, y = -1, f[1 << 25], val[1 << 25];
inline int lowbit(int x) { return x & -x; }
int main() {
  scanf("%d", &n);
  for (int t, i = 1; i <= n; ++i) scanf("%d", &t), val[1 << (i - 1)] = t;
  scanf("%d", &k);
  if (k == 1) scanf("%d", &x);
  if (k == 2) scanf("%d%d", &x, &y);
  f[0] = 1;
  for (int i = 1; i < (1 << n); ++i) {
    if (!val[i]) val[i] = val[i - lowbit(i)] + val[lowbit(i)];
    if (val[i] == x || val[i] == y) continue;
    long long res = 0;
    for (int j = i; j; j -= lowbit(j)) res += f[i - lowbit(j)];
    f[i] = res % 1000000007;
  }
  printf("%d", f[(1 << n) - 1]);
  return 0;
}
