#include <bits/stdc++.h>
using namespace std;
const int md = 1e9 + 7;
void Add(int &x, int y) {
  x += y;
  if (x >= md) x -= md;
}
int Fast(int x, int k) {
  int res = 1;
  while (k) {
    if (k & 1) res = 1ll * res * x % md;
    x = 1ll * x * x % md;
    k >>= 1;
  }
  return res;
}
int n, K;
int A[30];
int Sum[1 << 24];
int B[3], Id[1 << 24];
bool Check(int x) {
  for (int i = (0), i_END_ = (K - 1); i <= i_END_; ++i)
    if (Sum[x] == B[i]) return 1;
  return 0;
}
int Cnt[1 << 24];
int dp[1 << 24];
void Solve() {
  for (int i = (0), i_END_ = (n - 1); i <= i_END_; ++i) Id[1 << i] = i;
  dp[0] = 1;
  for (int i = (1), i_END_ = ((1 << n) - 1); i <= i_END_; ++i) {
    Sum[i] = min(Sum[i - (i & -i)] + A[Id[i & -i]], 1000000000 + 1);
    if (!Check(i)) {
      int pos = i;
      while (pos) {
        int k = pos & -pos;
        Add(dp[i], dp[i - k]);
        pos -= k;
      }
    }
  }
  printf("%d\n", dp[(1 << n) - 1]);
}
int main() {
  scanf("%d", &n);
  for (int i = (0), i_END_ = (n - 1); i <= i_END_; ++i) scanf("%d", &A[i]);
  scanf("%d", &K);
  for (int i = (0), i_END_ = (K - 1); i <= i_END_; ++i) scanf("%d", &B[i]);
  Solve();
  return 0;
}
