# dp[S][T] = 今までに詰めたおもちゃの集合がS、おもちゃ箱の集合がTのとき、 # Tの最後の箱のスペースの大きさ import sys readline = sys.stdin.readline N = int(readline()) A = list(map(int,readline().split())) M = int(readline()) B = list(map(int,readline().split())) dp = [[-1] * (1 << M) for i in range(1 << N)] dp[0][0] = 0 for S in range(1 << N): for T in range(1 << M): if dp[S][T] == -1: continue for toy in range(N): # 次に詰めるおもちゃ if (S >> toy) & 1: continue next_S = S | (1 << toy) if dp[S][T] >= A[toy]: # 今のスペースに詰められる if dp[next_S][T] < dp[S][T] - A[toy]: dp[next_S][T] = dp[S][T] - A[toy] else: # 詰められないので新しいおもちゃ箱を選ぶ # print(bin(S)[2:].zfill(N), bin(T)[2:].zfill(M), "新しいおもちゃ箱選ぶ") for box in range(M): if (T >> box) & 1: # print(box,"は使用済み") continue if B[box] < A[toy]: # 詰められない # print(B[box],"に",A[toy],"は詰められない") continue next_T = T | (1 << box) if dp[next_S][next_T] < B[box] - A[toy]: dp[next_S][next_T] = B[box] - A[toy] # print("next_S",bin(next_S)[2:].zfill(N),"next_T",bin(next_T)[2:].zfill(M),"空きは",B[box] - A[toy]) #for d in dp: # print(d) def popcnt(x): res = 0 while x: if x & 1: res += 1 x >>= 1 return res ans = M + 1 # dp[-1][おもちゃ箱]の状態で、-1で無い物を探す。 # おもちゃ箱に立っているbitが最も少ないものが答え for T in range(1 << M): if dp[-1][T] != -1: # print(bin(T)[2:].zfill(M),"のとき空きは",dp[-1][T]) bits = popcnt(T) if ans > bits: ans = bits if ans == M + 1: print(-1) else: print(ans)