N = int(input()) A = list(map(int, input().split())) M = int(input()) B = list(map(int, input().split())) B.sort(reverse=True) size = [0] for a in A: size += [s + a for s in size] dp = [0] * (1 << N) dp[0] = 1 ans = -1 for i, b in enumerate(B, 1): newDP = [0] * (1 << N) for S, ds in enumerate(dp): if ds: for T, sz in enumerate(size): if sz <= b: newDP[S | T] = 1 dp = newDP if dp[(1<