#include using namespace std; using ll = long long; using vll = vector; #define all(A) A.begin(),A.end() #define rep(i, n) for (ll i = 0; i < (ll) (n); i++) int main() { ll N,M; cin>>N; vll A(N); rep(i,N)cin>>A[i]; cin>>M; vll B(M); rep(i,M)cin>>B[i]; ll an=M+20; sort(all(B)); reverse(all(B)); sort(all(A)); do{ ll k=0; ll s=0; rep(i,N){ if(s+A[i]<=B[k]){ s+=A[i]; } else if(k==M-1){ k=1e17; break; } else { k++; s=0; i--; } } an=min(an,k+1); }while(next_permutation(all(A))); cout<<(an