eval'A,B,C,*R='+$<.read.split*?,;p 3.times.map{|i|2*[A+B,B+C,C+A].sort[~i]*R.sort[i]}.sum