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