import sequtils,strutils,algorithm var N = stdin.readline.parseInt A = stdin.readline.split.map(parseInt) M = stdin.readline.parseInt B = stdin.readline.split.map(parseInt) cnt = M + 1 F : array[2048,bool] F[0] = true B.sort(system.cmp) B.reverse A.sort(system.cmp) A.reverse proc hantei(X : openarray[int]):bool = if X.len == 0: return false var flag = F for b in X: var flag2 = flag for i in 0..<(1 shl N): var n = b var f = true for k,a in A: if (i and (1 shl k)) > 0: n -= a if n < 0: f = false break if f == true: for j in 0..<(1 shl N): if flag[j] == true: flag2[j or i] = true flag = flag2 return flag[(1 shl N) - 1] while hantei(B): discard B.pop cnt -= 1 if cnt <= M: echo cnt else: echo -1