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] if C[0] == max(C.values()): print("YES") else: print("NO")