def next_permutation(arr): i = len(arr) - 2 while i >= 0 and arr[i] >= arr[i + 1]: i -= 1 if i == -1: return False j = len(arr) - 1 while arr[j] <= arr[i]: j -= 1 arr[i], arr[j] = arr[j], arr[i] arr[i + 1:] = reversed(arr[i + 1:]) return True from itertools import permutations n = int(input()) A = sorted(map(int, input().split())) m = int(input()) + 1 B = list(reversed(sorted(map(int, input().split())))) a = m while True: T, i, j = B[:], 0, 0 while i < n and j < m - 1: if T[j] >= A[i]: T[j] -= A[i] i += 1 else: j += 1 a = min(a, j + 1) if not next_permutation(A): break print(a if a < m else -1)