n = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) count = [0]*n for i,j in enumerate(b): count[j]+=a[i] print("YES") if count.index(max(count))==0 else print("NO")