import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import static java.lang.System.in; public class Main { public static void main(String[] args) throws IOException { int numOfParticipants = 100; int[] pointsOfParticipants = new int[numOfParticipants + 1]; BufferedReader reader = new BufferedReader(new InputStreamReader(in)); int N = Integer.parseInt(reader.readLine()); String[] scores = reader.readLine().split(" "); String[] solvedByArray = reader.readLine().split(" "); for (int i = 0; i < N; i++) { int solvedBy = Integer.parseInt(solvedByArray[i]); int score = Integer.parseInt(scores[i]); if (solvedBy == 0) { pointsOfParticipants[100] += score; } else { pointsOfParticipants[solvedBy-1] += score; } } int champion = 0; int maxSoFar = Integer.MIN_VALUE; for (int i = 0; i < numOfParticipants+1; i++) { if (pointsOfParticipants[i] >= maxSoFar) { maxSoFar = pointsOfParticipants[i]; champion = i; } } if(champion==100) { System.out.println("YES"); } else { System.out.println("NO"); } } }