import scala.annotation.tailrec import scala.io.StdIn.* import scala.math.* @main def main = val Array(n, x, y, z) = readLine().split(' ').map(_.toInt) val pay = readLine().split(' ').map(_.toInt) val bill = Array(1000 -> x, 5000 -> y, 10000 -> z) for (money, count) <- bill.reverseIterator do var rest = count for i <- 0 until n do if pay(i) >= money then val use = min(rest, pay(i) / money) pay(i) -= use * money rest -= use for i <- (0 until n).sortWith((i, j) => pay(i) % money > pay(j) % money) do if rest > 0 && pay(i) >= 0 then rest -= 1 pay(i) -= money println(if pay.forall(_ < 0) then "Yes" else "No")