import java.util.HashMap; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); int []a = new int[N]; int []b = new int[N]; for(int i = 0; i < N; i++) { a[i] = scan.nextInt(); } for(int i = 0; i < N; i++) { b[i] = scan.nextInt(); } scan.close(); HashMap map = new HashMap(); int k = 0; for(int i = 0; i < N; i++) { if(b[i] == 0) { k += a[i]; }else { if(map.get(b[i]) != null) { map.put(b[i], map.get(b[i]) + a[i]); }else { map.put(b[i], a[i]); } } } for(int t : map.keySet()) { if(k < t) { System.out.println("NO"); System.exit(0); } } System.out.println("YES"); } }