n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) k_score = 0 participants = [0] * 100 # Participants 1-100 correspond to indexes 0-99 for i in range(n): if b[i] == 0: k_score += a[i] else: p_index = b[i] - 1 # Convert to 0-based index participants[p_index] += a[i] max_other = max(participants) print("YES" if k_score >= max_other else "NO")