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

r=0
d = [0]*101
for i in range(n):
    if b[i]==0:
        r += a[i]
    else:
        d[b[i]]+=a[i]

if r>=max(d):
    print("YES")
else:
    print("NO")