h=Hash[(?a..?z).map{|c|[c,gets.to_i]}] p "hewrd".chars.map{|c|h[c]}.inject(:*)*(h[?o]/2*(h[?o]-h[?o]/2))*(2..h[?l]).map{|i|i*(i-1)/2*(h[?l]-i)}.max