N = gets.to_i
Ss = gets.split.map(&:to_i)
INF = 10**9 + 1
M = 1 << N

def born?(xs, ys)
  return true if xs.size == M
  zs = []
  k = nil
  xs.each do |x|
    k = ys.bsearch_index{|y| y < x}
    return false unless k
    zs << ys[k]
    ys[k] = INF
  end
  born?((xs + zs).sort.reverse, ys)
end

ss = Ss.sort.reverse
xs = [ss[0]]
ys = ss; ys[0] = INF
puts born?(xs, ys) ? 'Yes' : 'No'