#include <bits/stdc++.h>
using namespace std;
int f[1 << 24], bn[5], v[26];
int n, k;
int main() {
  while (cin >> n) {
    for (int i = 0; i < n; ++i) cin >> v[i];
    cin >> k;
    for (int i = 0; i < k; ++i) cin >> bn[i];
    f[0] = 1;
    int s = 0, max = (1 << n) - 1;
    long long tmp;
    for (int i = 1; i <= max; ++i) {
      s = tmp = 0;
      for (int j = 0; j < n; ++j)
        if (i & (1 << j)) {
          s += v[j];
          tmp += f[i & (~(1 << j))];
        }
      for (int j = 0; j < k; j++)
        if (s == bn[j]) tmp = 0;
      f[i] = tmp % 1000000007;
    }
    cout << f[max] << endl;
  }
  return 0;
}
