#include <bits/stdc++.h>
using namespace std;
int n, s, all;
const int mod = 1e9 + 7;
long long sum[1 << 24], f[1 << 24], cant[3];
inline int lowbit(int x) { return x & (-x); }
inline void work(long long &x) {
  if (x >= mod) x -= mod;
}
int main() {
  cin >> n;
  all = (1 << n);
  for (int i = 0; i < n; ++i) scanf("%lld", &sum[1 << i]);
  cin >> s;
  for (int i = 0; i < s; ++i) scanf("%lld", &cant[i]);
  f[0] = 1;
  for (int i = 0; i < all; ++i) {
    sum[i] = sum[i ^ lowbit(i)] + sum[lowbit(i)];
    if (sum[i] == cant[0] || sum[i] == cant[1]) continue;
    for (int j = i; j; j ^= lowbit(j)) f[i] += f[i ^ lowbit(j)], work(f[i]);
  }
  cout << f[all - 1];
  return 0;
}
