n,A,B,w,*c=`dd`.split.map &:to_i p (2**n).times.map{|j|r=0;n.times.reduce(w){|s,i|j[i]<1?(r=0;s+c[i]):s-A+B*r+=1}}.min