i=input N,D=int(i()),[0]*101 g=lambda:list(map(int,i().split())) A,B=g(),g() for i in range(N):D[B[i]]+=A[i] print(('NO','YES')[D[0]==max(D)])