The optimal solution isn't always the median. Instead, we need to try every possible target value between the minimum and maximum numbers in the list. For each potential target value, we need to consider two options for each number:
The algorithm should choose the cheaper option for each number. The total cost for a given target value is the sum of the optimal choices for each number. We then pick the target value that gives us the minimum total cost.