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