lst=[0]*101 n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) for i in range(n): if b[i]!=0:lst[b[i]]+=a[i] max_value=max(lst) tmp1=0 for i in range(n): if b[i]==0:tmp1+=a[i] print(["NO","YES"][tmp1>=max_value])