N=int(input()) A=list(map(int,input().split())) B=list(map(int,input().split())) D={} for i in range(N): if B[i] in D:D[B[i]]+=A[i] else:D[B[i]]=A[i] #print(D) top=0 iD=0 for k,v in D.items(): if v==top and k==0:iD=0 if v>top:top,iD=v,k print(('NO','YES')[iD==0])