import itertools N = int(input()) A = sorted(list(map(int, input().split()))) M = int(input()) B = sorted(list(map(int, input().split())), reverse=True) for i, b in enumerate(B, 1): max_b = 0 max_Ac = 0 tmp = tuple([0] * len(A)) it = itertools.product((0, 1), repeat=len(A)) next(it) for t in it: A_c = tuple(itertools.compress(A, t)) if max_b <= sum(A_c) <= b and max_Ac <= max(A_c): max_b = sum(A_c) max_Ac = max(A_c) tmp = t A = list(itertools.compress(A, (not x for x in tmp))) if not A: print(i) break else: print(-1)