#include <bits/stdc++.h>
using namespace std;
const int N = 24;
const long long MOD = 1000000007;
long long num_paths[1 << N];
long long a[N];
long long b[2];
int n, m;
void read_input() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  cin >> m;
  for (int i = 0; i < m; ++i) {
    cin >> b[i];
  }
}
int main() {
  read_input();
  num_paths[0] = 0;
  for (int i = 0; i < 1 << n; ++i) {
    int j = __builtin_ctz(i);
    num_paths[i] = num_paths[i ^ (1 << j)] + a[j];
  }
  for (int i = 0; i < (1 << n); ++i) {
    for (int j = 0; j < m; ++j) {
      if (num_paths[i] == b[j]) num_paths[i] = 0;
    }
  }
  num_paths[0] = 1;
  for (int i = 1; i < (1 << n); ++i) {
    if (num_paths[i] != 0) {
      num_paths[i] = 0;
      for (int j = 0; j < n; ++j) {
        if (i & (1 << j)) {
          num_paths[i] += num_paths[i ^ (1 << j)];
        }
      }
    }
    num_paths[i] %= MOD;
  }
  cout << num_paths[(1 << n) - 1];
  return 0;
}
