import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] toys = new int[n]; for (int i = 0; i < n; i++) { toys[i] = sc.nextInt(); } Arrays.sort(toys); int m = sc.nextInt(); int[] boxes = new int[m]; for (int i = 0; i < m; i++) { boxes[i] = sc.nextInt(); } Arrays.sort(boxes); int right = m - 1; TreeMap using = new TreeMap<>(); using.put(Integer.MAX_VALUE, 0); for (int i = n - 1; i >= 0; i--) { int key = using.ceilingKey(toys[i]); if (key == Integer.MAX_VALUE) { if (right < 0 || boxes[right] < toys[i]) { System.out.println(-1); return; } using.put(boxes[right] - toys[i], using.getOrDefault(boxes[right] - toys[i], 0) + 1); right--; } else { if (using.get(key) == 1) { using.remove(key); } else { using.put(key, using.get(key) - 1); } using.put(key - toys[i], using.getOrDefault(key - toys[i], 0) + 1); } } System.out.println(m - right - 1); } }