Every order of operations has the same total cost. The answer is
Compute the sum and minimum in one pass. The time complexity is and the additional space complexity is .
Proof
Replacing adjacent values with decreases the sum of the sequence by
which is exactly the cost of the operation.
The total cost therefore equals the initial sum minus the final remaining value. Regardless of the order of operations, that value is the minimum of the original sequence, giving the formula above.