N = int(input()) score = [0]*(100 + 1) A = list(map(int, input().split())) B = list(map(int, input().split())) for a, b in zip(A, B): score[b] += a M = max(score) if M == score[0]: print('YES') else: print('NO')