#coding: UTF-8 import sys import re import itertools from collections import deque ### defs ### ### main ### N = int(sys.stdin.readline()) A = list(map(int,sys.stdin.readline().split())) B = list(map(int, sys.stdin.readline().split())) score = [0]*100 k = 0 for a,b in zip(A,B): if(b==0): k += a else: score[b-1] += a mx = max(score) if(k>=mx): print('YES') else: print('NO')