N=int(raw_input())
A=map(int,raw_input().split())
B=map(int,raw_input().split())
score=[0 for i in range(101)]
maxScore=0
for a,b in zip(A,B):
    score[b]+=a
    maxScore=max(maxScore,score[b])
if maxScore==score[0]:
    print "YES"
else:
    print "NO"