N = gets.to_i
Ss = gets.split.map(&:to_i)

def born?(xs, ys)
  return true if ys.empty?
  xs.zip(ys).each do |x, y|
    return false if x <= y
  end
  n = xs.size
  born?((xs + ys.take(n)).sort.reverse, ys.drop(n))
end

puts born?([Ss.max], Ss.sort.reverse.drop(1)) ? 'Yes' : 'No'