import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.stream.Stream;

public class No00000216_Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		int[] a = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		int[] b = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		int[] other = new int[100];

		int point = 0;
		for(int i = 0; i < n; i++) {
			if(b[i] == 0) {
				point += a[i];
			} else {
				other[b[i] - 1] += a[i];
			}
		}
		Arrays.sort(other);
		System.out.println(point >= other[99] ? "YES" : "NO");
	}
}