Vasya recently develop new algorithm optimize reception customer flow consider follow problemLet queue cashier contain n people characterize positive integer ai time need work customer what special cashier serve customer simultaneously however customer need ai aj time serve time need work customer equal maxaiaj please note work customer uninterruptable process people simultaneously come cashier mean begin serve simultaneously finish simultaneously possible waitvasya algorithm ingenious heuristic long queue person wait people stand queue send simultaneously if queue customer number go cashier serve ai time note total number phase serve customer equal n2Vasya think method help cope queue hate that s ask work program determine minimum time queue serve algorithm