you inventory different colored ball customer want order ball colorthe customer weirdly value color ball each color ball value number ball color currently inventory for example 6 yellow ball customer pay 6 yellow ball after transaction 5 yellow ball leave yellow ball value 5 ie value ball decreases sell customerYou give integer array inventory inventoryi represent number ball ith color initially you give integer order represent total number ball customer want you sell ball orderreturn maximum total value attain selling order color ball as answer large return modulo 109 7 Example 1input inventory 25 order 4output 14explanation sell 1st color 1 time 2 2nd color 3 time 5 4 3the maximum total value 2 5 4 3 14example 2input inventory 35 order 6output 19explanation sell 1st color 2 time 3 2 2nd color 4 time 5 4 3 2the maximum total value 3 2 5 4 3 2 19 Constraints1 inventorylength 1051 inventoryi 1091 order minsuminventoryi 109