A gardener is landscaping a garden and must move a large amount of dirt in the process.
The garden is a row of $N$ flowerbeds ($1 \le N \le 100$). Flowerbed $i$ currently holds $A_i$ units of dirt, and the gardener wants it to hold $B_i$ units instead. Every $A_i$ and $B_i$ is an integer between $0$ and $10$.
Three operations are available:
Compute the minimum total cost to make every flowerbed $i$ hold exactly $B_i$ units of dirt.
In the first example there are 4 flowerbeds holding 1, 2, 3, and 4 units of dirt, with targets of 4, 3, 2, and 0 units. Buying, removing, and moving one unit cost 100, 200, and 1 respectively.
One unit of dirt must be removed (from flowerbed 4) at a cost of 200. The remaining dirt is rearranged by moving 3 units from flowerbed 4 to flowerbed 1 and 1 unit from flowerbed 3 to flowerbed 2, for a moving cost of 10. The total is 210.