N = int(input()) questions = [(int(x),int(y)) for x,y in zip(input().split(),input().split())] score = sum([x[0] for x in questions if not x[1]]) participants_score = [0 for x in range(N)] for question in [x for x in questions if x[1]]: t_score,correcter = question participants_score[correcter - 1]+=t_score winners_score = max(participants_score) is_won = score >= winners_score print("YES" if is_won else "NO")