give wooden stick length n unit the stick label 0 n for example stick length 6 label followsGiven integer array cut cutsi denote position perform cut atYou perform cut order change order cut wishthe cost cut length stick cut total cost sum cost cut when cut stick split small stick ie sum length length stick cut please refer example well explanationreturn minimum total cost cut Example 1input n 7 cut 1345output 16explanation use cut order 1 3 4 5 input lead follow scenariothe cut rod length 7 cost 7 the second cut rod length 6 ie second cut rod length 4 cut rod length 3 the total cost 7 6 4 3 20rearranging cut 3 5 1 4 example lead scenario total cost 16 show example photo 7 4 3 2 16example 2input n 9 cut 56142output 22explanation if try give cut order cost 25there order total cost 25 example order 4 6 5 2 1 total cost 22 minimum possible Constraints2 n 1061 cutslength minn 1 1001 cutsi n 1all integer cut array distinct