#python 3.5.2

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

Scores = {}

for i, a in enumerate(A):
    if B[i] in Scores.keys():
        Scores[B[i]] += a
    else:
        Scores[B[i]] = a

res = sorted(Scores.items(), key=lambda x: x[1])
maxScore = res[-1][1]

if not 0 in Scores.keys():
    print("NO")
else:
    if Scores[0] == maxScore:
        print("YES")
    else:
        print("NO")