import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n]; for(int i = 0; i < n; i++) { a[i] = sc.nextInt(); } int m = sc.nextInt(); int[] b = new int[m]; for(int i = 0; i < m; i++) { b[i] = sc.nextInt(); } Arrays.sort(b); int[] sumb = new int[m + 1]; for(int i = 1; i < m + 1; i++) { sumb[i] = sumb[i - 1] + b[m - i]; } int p = (int)Math.pow(2, n); int[] dp = new int[p]; int[] suma = new int[p]; for(int i = 1; i < p; i++) { for(int j = 0; j < n; j++) { if((i & (1 << j)) != 0) suma[i] += a[j]; } } for(int i = 0; i < p; i++) { dp[i] = 100; } dp[0] = 0; for(int i = 1; i < p; i++) { for(int j = 0; j < n; j++) { if((i & (1 << j)) != 0) { int i1 = i - (1 << j); if(dp[i1] >= 0) { int r = sumb[dp[i1]] - suma[i1]; if(r >= a[j]) { dp[i] = Math.min(dp[i], dp[i1]); } else { if(a[j] <= b[m - dp[i1] - 1]) dp[i] = Math.min(dp[i], dp[i1] + 1); } } } } if(dp[i] == 100) dp[i] = -1; } System.out.println(dp[p - 1]); } }