#include using namespace std; const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1}; int N,M; vector A,B; int main(){ cin >> N ; A.resize(N); for (int i = 0; i < N; i++){ cin >> A[i]; } cin >> M; B.resize(M); for (int i = 0; i < M; i++){ cin >> B[i]; } sort(A.begin(), A.end()); sort(B.rbegin(), B.rend()); int ans = 810; do{ int pos = 0; for (int i = 0; i < M; i++){ int rest = B[i]; while (pos < N and rest >= A[pos]){ rest -= A[pos]; pos++; } if (pos >= N){ ans = min(ans, (i + 1)); break; } } }while(next_permutation(A.begin(), A.end())); if (ans >= 810){ ans = -1; } cout << ans << endl; }