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