N=int(raw_input()) A=map(int,raw_input().split()) M=int(raw_input()) B=map(int,raw_input().split()) B.sort() B.reverse() dp=[(-1,-1) for i in range(1<= A[i]: na,nb=n_box,rest-A[i] elif n_box=A[i]: na,nb=n_box+1,B[n_box]-A[i] else: na,nb=100,100 if a > na or( a==na and b < nb ): a,b=na,nb dp[mask]=(a,b) #print format(mask,'b'), a,b return a,b a,b=rec( (1<N: print -1 else: print a