public class No_216 { public static void main(String[] args) { java.util.Scanner sc = new java.util.Scanner(System.in); int n = sc.nextInt(); int[] score = new int[n]; int[] user = new int[n]; for (int i = 0; i < n; i++) { score[i] = sc.nextInt(); } for (int i = 0; i < n; i++) { int j = sc.nextInt(); user[j] += score[i]; } sc.close(); boolean b = true; for (int i = 1; i < n; i++) { if (user[0] < user[i]) { b = false; break; } } if (b) { System.out.println("YES"); } else { System.out.println("NO"); } } }