import java.util.*; import java.math.*; import java.text.*; public class Main { private static Scanner sc = new Scanner(System.in); public static void main(String[] args) throws Exception { int[] sum = new int[101]; int[] score = new int[100]; int n = sc.nextInt(); for (int i = 0;i < n;i++) { score[i] = sc.nextInt(); } for (int i = 0;i < n;i++) { sum[sc.nextInt()] += score[i]; } int ret = 0; for (int i = 0;i < 101;i++) { ret = Math.max(ret, sum[i]); } if (ret == sum[0]) { System.out.println("YES"); } else { System.out.println("NO"); } } }