#include "bits/stdc++.h" using namespace std; bool dp[1 << 10]; bool dp2[1 << 10]; int main(){ int N; cin >> N; vector A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } int M; cin >> M; vector B(N); for (int i = 0; i < M; i++) { cin >> B[i]; } sort(B.begin(), B.end()); reverse(B.begin(), B.end()); dp[0] = true; for (int i = 0; i < M; i++) { for (int j = 0; j < (1 << N); j++) { int c = 0; for (int k = 0; k < N; k++) { if ((j >> k) % 2 == 0) continue; c += A[k]; } if (c > B[i]) continue; for (int k = (1 << N) - 1; k >= 0; k--) { dp2[j | k] |= dp[k]; } } for (int k = (1 << N) - 1; k >= 0; k--) { dp[k] = dp2[k]; } if (dp[(1 << N) - 1]){ cout << (i + 1) << endl; return 0; } } cout << -1 << endl; }