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