import java.util.Arrays; import java.util.LinkedList; import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); int[] as = new int[N]; int[] bs = new int[N]; for(int i = 0; i < N; i++){ final int a = sc.nextInt(); as[i] = a; } int[] points = new int[101]; for(int i = 0; i < N; i++){ final int b = sc.nextInt(); points[b] += as[i]; } int max = Integer.MIN_VALUE, max_pos = -1; for(int i = 0; i < 101; i++){ if(max < points[i]){ max = points[i]; max_pos = i; } } System.out.println(max_pos == 0 ? "YES" : "NO"); } }