nn = gets.to_i
ss = gets.split.map(&:to_i).sort{|a,b|b<=>a}

# 配列に切る
sorted = [[ss[0]]]
1.upto(nn) do |n|
  from = 2**(n-1)
  to = 2**n-1
  sorted << ss[from..to]
end

can = true
prev_min = sorted[0][-1]
prev_min_cnt = 0

# 1,2,4個..に区切って処理
1.upto(nn) do |n|
  ar = sorted[n].sort

  max = ar[-1]
  min = ar[0]

  idx = ar.bsearch_index{|x|x>min}
  min_to = idx.nil? ? ar.size-1 : idx-1
  min_cnt = min_to + 1

  idx = ar.bsearch_index{|x|x>=max}
  max_cnt = ar.size - idx

  # maxが前回配列の最小より小さければOK
  if max < prev_min

  # maxが前回配列の最小と同じ場合
  else
    if prev_min_cnt< max_cnt
      can = false
      break
    end
  end
  prev_min = min
  prev_min_cnt = min_cnt
end

puts can ? 'Yes' : 'No'