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

def born?(xs, ys)
  return true if ys.empty?
  xs = xs.sort.reverse
  zs = []
  xs.each do |x|
    if i = ys.index{|y| y < x}
      zs << ys[i]
      ys.delete_at(i)
    else
      return false
    end
  end
  born?(xs + zs, ys)
end

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