n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

score = [0]*100
score_k = 0
for i in range(n):
    if b[i] == 0:
        score_k += a[i]
    else:
        score[b[i]-1] += a[i]

sorted_score = sorted(score, reverse=True)

if score_k >= sorted_score[0]:
    res = 'YES'
else:
    res = 'NO'

print(res)