import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.math.*; public class Main { public static void main(String[] args)throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); int n = Integer.parseInt(br.readLine()); String[] str1 = br.readLine().split(" "); String[] str2 = br.readLine().split(" "); int[] p = new int [101]; int max = 0; int sum = 0; for(int i = 0; i < n; i++){ int a = Integer.parseInt(str1[i]); int b = Integer.parseInt(str2[i]); if(b!=0){ p[b] += a; max = Math.max(max,p[b]); }else{ sum += a; } } if(max>sum){ sb.append("NO"); }else{ sb.append("YES"); } System.out.println(sb); } }