#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   int n, k, x, sum, a[24], BadPoint[2], dp[(1 << 24)];   int32_t main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     cin >> k;     for (int i = 0; i < k; i++) cin >> BadPoint[i];     dp[0] = 1;     for (int mask = 1; mask < (1 << n); mask++) {       sum = 0;       for (int i = 0; i < n; i++) {         if ((mask >> i) & 1) {           dp[mask] += dp[(mask ^ (1 << i))];           if (dp[mask] >= MOD) dp[mask] -= MOD;           sum += a[i];         }       }       for (int i = 0; i < k; i++)         if (sum == BadPoint[i]) dp[mask] = 0;     }     cout << dp[(1 << n) - 1];   }   