#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int maxn = 24;
const int mod = 1000000007;
int dis[1 << maxn], f[1 << maxn];
void solve(int x) {
  for (int k = x, j; k; k ^= j) {
    j = k & -k;
    if ((f[x] += f[x ^ j]) >= mod) f[x] -= mod;
  }
}
int main() {
  int n, m;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &dis[1 << i]);
  scanf("%d", &m);
  int x, y;
  if (m > 0) scanf("%d", &x);
  if (m > 1) scanf("%d", &y);
  f[0] = 1;
  for (int i = 1; i <= (1 << n) - 1; i++) {
    int j = i & -i;
    dis[i] = dis[i ^ j] + dis[j];
    if (dis[i] == x || dis[i] == y) continue;
    solve(i);
  }
  printf("%d", f[(1 << n) - 1]);
  return 0;
}
