#include <bits/stdc++.h>
using namespace std;
const int MAXN = 24;
const int mod = 1000000007;
int n, k;
long long a[MAXN], b[4];
long long dp[(1 << MAXN)];
void read() {
  int i;
  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    cin >> a[i];
  }
  scanf("%d", &k);
  for (i = 0; i < k; ++i) {
    cin >> b[i];
  }
}
void solve() {
  for (int i = 1; i < (1 << n); ++i) {
    int j = __builtin_ctz(i);
    dp[i] = dp[i ^ (1 << j)] + a[j];
  }
  for (int i = 0; i < (1 << n); ++i) {
    for (int j = 0; j < k; ++j) {
      if (dp[i] == b[j]) {
        dp[i] = -1;
        break;
      }
    }
  }
  dp[0] = 1;
  for (int i = 1; i < (1 << n); ++i) {
    if (dp[i] < 0) {
      dp[i] = 0;
    } else {
      dp[i] = 0;
      for (int j = 0; j < n; ++j) {
        if (i & (1 << j)) {
          dp[i] += dp[i ^ (1 << j)];
        }
      }
    }
    dp[i] %= mod;
  }
  cout << dp[(1 << n) - 1] << endl;
}
int main() {
  read();
  solve();
  return 0;
}
