import java.util.Scanner; import java.util.ArrayList; import java.util.Collections; public class Main { static public void main(String[] args) { Scanner sc = new Scanner(System.in); int size = sc.nextInt(); int emptyScore = 0; int i; ArrayList scoreList = new ArrayList(); for (i = 0; i < size; i++) //各問題の点数記録 scoreList.add(sc.nextInt()); ArrayList answerList = new ArrayList(); for (i = 0; i < size; i++) //各問題の正答者記録 answerList.add(sc.nextInt()); ArrayList peopleScore = new ArrayList(); //出場者番号ごとの点数 for (i = 0; i < 101; i++) peopleScore.add(i, 0); for (i = 0; i < size; i++) { if (answerList.get(i) > 0) { int peopleNum = answerList.get(i); int peopleSc = peopleScore.get(peopleNum); int addScore = scoreList.get(i); peopleScore.set(peopleNum, peopleSc+addScore); } else emptyScore += scoreList.get(i); } if (emptyScore >= Collections.max(peopleScore)) System.out.println("YES"); else System.out.println("NO"); } }