N = int(input())
score = [0] * 101
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for i in range(N):
    score[B[i]] += A[i]
if max(score) == score[0]:
    print("YES")
else:
    print("NO")