import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int[] a = new int[N]; int[] score = new int[101]; for(int i = 0; i < N; i++) { a[i] = sc.nextInt(); } int[] b = new int[N]; for(int i = 0; i < N; i++) { b[i] = sc.nextInt(); score[b[i]] += a[i]; } int max = 0; for(int i = 1; i < 101; i++) { max = Math.max(max, score[i]); } String ans = "NO"; if(max <= score[0]) ans = "YES"; System.out.println(ans); } }