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

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

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