n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
b = gets.chomp.split(" ").map(&:to_i)
score = Array.new(101,0)
b.each_index{|i|
score[b[i]] += a[i]
}
if score[0] == score.max
 puts "YES"
else
 puts "NO"
end