Given an array of integers, the cost to change an element is the absolute difference between its initial value and its new value.For example, if an element is initially 10, it can be changed to 7 or 13 for a cost of 3. Task. Determine the minimum total cost to make the array sorted along…