#include <bits/stdc++.h>
int a[24], b[24], state[1 << 24], routesum[1 << 24];
int n, k;
using namespace std;
inline void init() {
  state[0] = 1;
  routesum[0] = 0;
}
int main() {
  init();
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    routesum[1 << i] = a[i];
  }
  scanf("%d", &k);
  for (int i = 0; i < k; ++i) {
    scanf("%d", &b[i]);
  }
  for (int i = 1; i < (1 << n); ++i) {
    int mylb = i & (-i);
    routesum[i] = routesum[i - mylb] + routesum[mylb];
    if (routesum[i] == b[0] || routesum[i] == b[1]) continue;
    int j, jlb;
    for (j = i; j > 0; j -= jlb) {
      jlb = j & (-j);
      int ind = i - jlb;
      state[i] += state[i - jlb];
      if (state[i] > 1000000007) state[i] -= 1000000007;
    }
  }
  printf("%d\n", state[(1 << n) - 1]);
  return 0;
}
