import java.io.*; import java.util.*; public class Main_yukicoder50 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Printer pr = new Printer(System.out); final int INF = Integer.MAX_VALUE; int n = sc.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); } int m = sc.nextInt(); List b = new ArrayList<>(); for (int i = 0; i < m; i++) { b.add(sc.nextInt()); } Collections.sort(b); Deque> st = new ArrayDeque<>(); Deque stn = new ArrayDeque<>(); st.add(new ArrayList()); stn.add(0); int min = INF; while (!st.isEmpty()) { List e = st.pop(); int en = stn.pop(); if (en == n) { Collections.sort(e); boolean flag = true; for (int i = e.size() - 1, j = b.size() - 1; i >= 0; i--, j--) { if (j < 0 || b.get(j) < e.get(i)) { flag = false; break; } } if (flag) { min = Math.min(min, e.size()); } } else { for (int i = 0; i < e.size(); i++) { List tmp = new ArrayList<>(e); tmp.set(i, tmp.get(i) + a[en]); st.push(tmp); stn.push(en + 1); } List tmp = new ArrayList<>(e); tmp.add(a[en]); st.push(tmp); stn.push(en + 1); } } if (min == INF) { pr.println(-1); } else { pr.println(min); } pr.close(); sc.close(); } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }