n=int(input())
sl=list(map(int,input().split()))
tl=input().split()
d={}
for i in range(n):
    if tl[i] not in d:
        d[tl[i]]=sl[i]
    else:
        d[tl[i]]+=sl[i]

dic2 = sorted(d.items(), key=lambda x:x[1], reverse=True)
if '0' not in d:
    print("NO")
elif d['0']==dic2[0][1]:
    print("YES")
else:
    print("NO")