N=int(input()) A=list(map(int,input().split())) M=int(input()) B=list(map(int,input().split())) B.sort(reverse=True) def check(A,B): if sum(A)==0: return 1 if sum(A)>sum(B): return 0 ANS=0 A=list(A) B=list(B) for i in range(len(B)): if B[i]>=A[0]: B[i]-=A[0] if check(tuple(A[1:]),tuple(B))==1: ANS=1 B[i]+=A[0] return ANS ANS=-1 for i in range(len(B)+1): if check(A,B[:i])==1: ANS=i break print(ANS)