import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Map; public class No216 { public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new InputStreamReader( System.in)); int N = Integer.parseInt(br.readLine()); int[] a = strToIntArray(br.readLine()); int[] b = strToIntArray(br.readLine()); Map map = new HashMap(); // 途中経過 int sum = 0; for (int i = 0; i < N; i++) { if (b[i] == 0) { sum += a[i]; } else { if (map.containsKey(a[i])) { int score = map.get(b[i]); map.put(b[i], a[i] + score); } else { map.put(b[i], a[i]); } } } int max = 0; for (int i : map.values()) { max = Math.max(max, i); } if (max <= sum) { System.out.println("YES"); } else { System.out.println("NO"); } } catch (Exception e) { System.err.println("Error:" + e.getMessage()); } } static int[] strToIntArray(String S) { String[] strArray = S.split(" "); int[] intArray = new int[strArray.length]; for (int i = 0; i < strArray.length; i++) { intArray[i] = Integer.parseInt(strArray[i]); } return intArray; } }