N = int(input()) scores = list(map(int, input().split())) people = list(map(int, input().split())) s = [0] * 101 for score, person in zip(scores, people): s[person] += score if s[0] == max(s): print("YES") else: print("NO")