from itertools import permutations INF = 1 << 60 N = int(input()) A = list(map(int, input().split())) M = int(input()) B = list(map(int, input().split())) def put(xs) -> int: p = 0 caps = [0] * N for x in xs: while p < N and caps[p]+x > B[p]: p += 1 if p == N: return -1 caps[p] += x return p+1 ans = INF for ps in permutations(A): res = put(ps) if res == -1: continue ans = min(ans, res) if ans == INF: print(-1) else: print(ans)