#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int n, m, b1, b2, dis[1 << 24], f[1 << 24];
void upd(int &x, int y) { (x += y) >= mod && (x -= mod); }
void solve(int x) {
  for (int i = x, j; i; i ^= j) j = i & -i, upd(f[x], f[x ^ j]);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &dis[1 << i]);
  scanf("%d", &m);
  if (m > 0) scanf("%d", &b1);
  if (m > 1) scanf("%d", &b2);
  f[0] = 1;
  int msk = (1 << n) - 1;
  for (int i = 1; i <= msk; ++i) {
    int j = i & -i;
    dis[i] = dis[i ^ j] + dis[j];
    if (dis[i] == b1 || dis[i] == b2) continue;
    solve(i);
  }
  printf("%d\n", f[msk]);
  return 0;
}
