import java.util.*; public class Run { public static void main (String arg[]) { Scanner scan = new Scanner(System.in); String ans = "YES"; int N = scan.nextInt(); ArrayList point = new ArrayList<>(); HashMap solver = new HashMap<>(); int tmp; for (int i = 0; i < N; i++) point.add(scan.nextInt()); for (int i = 0; i < N; i++) { tmp = scan.nextInt(); if (solver.containsKey(tmp)) solver.put(tmp, solver.get(tmp) + point.get(i)); else solver.put(tmp, point.get(i)); } if (!solver.containsKey(0)) ans = "NO"; else { int max; max = solver.values().stream().max((a, b) -> a.compareTo(b)).get(); if (solver.get(0) < max) ans = "NO"; } System.out.println(ans); } }