#include <bits/stdc++.h>
using namespace std;
const int Mo = 1000000007;
int f[1 << 24], a[30], b[2];
int main() {
  f[0] = 1;
  int N, M, i, j;
  cin >> N;
  for (i = 0; i < N; i++) cin >> a[i];
  cin >> M;
  for (i = 0; i < M; i++) cin >> b[i];
  int MAX = (1 << N) - 1;
  for (i = 1; i <= MAX; i++) {
    int s = 0;
    for (j = 0; j < N; j++)
      if (i & (1 << j)) {
        f[i] = (f[i] + f[i ^ (1 << j)]) % Mo;
        s += a[j];
      }
    if (s == b[0] || s == b[1]) f[i] = 0;
  }
  cout << f[MAX] << endl;
}
