#include <bits/stdc++.h>
using namespace std;
const int M = 1000000007;
long long dp[1 << 24], a[30];
int main() {
  int n, k;
  int x = -1, y = -1;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int mask = 1 << n;
  cin >> k;
  if (k == 1) cin >> x;
  if (k == 2) cin >> x >> y;
  dp[0] = 1;
  for (int i = 1; i < mask; i++) {
    long long sum = 0;
    for (int j = 0; j < n; j++) {
      if ((1 << j) & i) {
        sum += a[j];
        dp[i] += dp[i ^ (1 << j)];
        if (dp[i] >= M) dp[i] -= M;
      }
    }
    if (sum == x || sum == y) dp[i] = 0;
  }
  cout << dp[mask - 1] << endl;
  return 0;
}
