You have numbers. You can change each to any value. The cost of changing to is . Make the array non-decreasing with minimum total cost.
This is the classic Slope Trick problem. Naive DP: = min cost for first elements with . With , you can't store all values. You'll track the function's shape through its slope-change points. The solution is similar to Sonya, but without the strictly-increasing transform.