import sys,itertools input=lambda:sys.stdin.readline().rstrip() N=int(input()) A=list(map(int,input().split())) M=int(input()) B=sorted(list(map(int,input().split())))[::-1] A=itertools.permutations(A) ans=-1 for i in A: temp=[0 for i in range(M)] for j in i: for k in range(M): if temp[k]+j<=B[k]: temp[k]+=j break else: break else: ans=max(ans,M-temp.count(0)) print(ans)