N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) score = [0 for _ in range(101)] for a, b in zip(A, B): score[b] += a if score[0]==max(score): print("YES") else: print("NO")