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