#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const int Maxn = 25, Maxm = 300005, Mo = 1000000007,
          sp[8][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
const long long oo = INT_MAX >> 2;
struct Tree {
  int l, r, cnt;
};
struct edge {
  int u, v, len;
};
struct node {
  int x, y;
};
typedef int IArr[Maxn];
typedef long long LArr[Maxn];
typedef double DArr[Maxn];
pair<int, int> root;
IArr a, bd;
long long f[1 << 24], sum[1 << 24];
int n, m, i, j, k;
int main() {
  ios::sync_with_stdio(0);
  map<long long, int> fd;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  cin >> k;
  for (i = 1; i <= k; i++) cin >> bd[i];
  for (i = 0; i < n; i++) fd[1 << i] = i + 1;
  f[0] = 1;
  for (i = 1; i <= (1 << n) - 1; i++) {
    sum[i] = sum[i - (i & -i)] + a[fd[i & -i]];
    if (sum[i] == bd[1] || sum[i] == bd[2]) continue;
    int p = i;
    while (p) {
      int k = (p & -p);
      p -= k;
      f[i] += f[i - k];
      if (f[i] > Mo) f[i] -= Mo;
    }
  }
  cout << f[(1 << n) - 1] << endl;
}
