n = int(input()) score = list(map(int, input().split())) player = list(map(int, input().split())) current = [0]*n for i in player: current[i] = current[i] + score[i] if current[0] == max(current): print('YES') else: print('NO')