#include #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; const int INF=1<<29; int n,m,a[10],b[10]; int used[10],ans; void dfs(int i){ if(i==n){ ans=min(ans,m-count(used,used+m,0)); return; } rep(j,m) if(used[j]+a[i]<=b[j]) { used[j]+=a[i]; dfs(i+1); used[j]-=a[i]; } } int main(){ scanf("%d",&n); rep(i,n) scanf("%d",&a[i]); scanf("%d",&m); rep(j,m) scanf("%d",&b[j]); sort(a,a+n,greater()); sort(b,b+m); ans=INF; dfs(0); printf("%d\n",ans