a chef collect data satisfaction level n dish Chef cook dish 1 unit timeliketime coefficient dish define time take cook dish include previous dish multiply satisfaction level ie timei satisfactioniReturn maximum sum liketime coefficient chef obtain dish preparationdishe prepare order chef discard dish maximum value Example 1input satisfaction 18059output 14explanation after remove second dish maximum total liketime coefficient equal 11 02 53 14each dish prepare unit timeexample 2input satisfaction 432output 20explanation dish prepare order 21 32 43 20example 3input satisfaction 145output 0explanation People like dish no dish prepare Constraintsn satisfactionlength1 n 5001000 satisfactioni 1000