eval'*A,G='+gets.split*?, x=500 A.map{|a|G-=[a,G/x].min*x x/=[5,2][$.^=1]} puts G>0?:NO: :YES