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]; } int kScore = user[0]; java.util.Arrays.sort(user); int maxScore = user[n - 1]; String ans = kScore >= maxScore ? "YES" : "NO"; System.out.println(ans); } }