Input: arr[] = { 2, 5, 6, 9, 10, 12, 15 }, A = 1, B = 2
Output: 32
Explanation:
Increment arr[0] by 8, arr[1] by 5, arr[2] by 4, arr[3] by 1, arr[4] by 0. Decrement arr[5] by 2, arr[6] by 5.
Therefore, arr[] modifies to { 10, 10, 10, 10, 10, 10, 10 }.
Therefore, total cost required = (8 + 5 + 4 + 1 + 0) * 1 + (2 + 5) * 2 = 18 + 14 = 32
Input: arr[] = { 2, 3, 4 }, A = 10, B = 1
Output: 3