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