n = int(input()) A = list(map(int,input().split())) m = int(input()) B = sorted(list(map(int,input().split())),reverse=True) dp = [0]*(1<> j & 1: count += A[j] if count <= b: dp[bit^mask] = 1 if dp[-1]: print(i) exit() print(-1)