#coding=UTF-8 N=int(input()) mojir=input() hyo=mojir.split(" ") a=list(range(0,N,1)) for idx in range(0,N,1): a[idx]=int(hyo[idx]) mojir=input() hyo=mojir.split(" ") b=list(range(0,N,1)) for idx in range(0,N,1): b[idx]=int(hyo[idx]) tokuten=list(range(0,100+1,1)) for idx in range(0,100+1,1): tokuten[idx]=0 for idx in range(0,N,1): tokuten[b[idx]]=tokuten[b[idx]]+a[idx] if max(tokuten)==tokuten[0]: print("YES") else: print("NO")