import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int []a = new int[N];
		int []b = new int[N];
		for(int i = 0; i < N; i++) {
			a[i] = scan.nextInt();
		}
		for(int i = 0; i < N; i++) {
			b[i] = scan.nextInt();
		}
		scan.close();
		HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
		int k = 0;
		for(int i = 0; i < N; i++) {
			if(b[i] == 0) {
				k += a[i];
			}else {
				if(map.get(b[i]) != null) {
					map.put(b[i], map.get(b[i]) + a[i]);
				}else {
					map.put(b[i], a[i]);
				}
			}
		}
		for(int t : map.keySet()) {
			if(k < map.get(t)) {
				System.out.println("NO");
				System.exit(0);
			}
		}
		System.out.println("YES");
	}
}