import sys readline=sys.stdin.readline N=int(readline()) point=[0]*(N+1) A=list(map(int,readline().split())) B=list(map(int,readline().split())) for a,b in zip(A,B): point[b]+=a if max(point)==point[0]: ans="YES" else: ans="NO" print(ans)