Santa Corporation delivers presents to children all over the world between Christmas Eve night and Christmas morning. Every santa who volunteers for delivery receives one high tech sleigh, and the trunk of that sleigh is connected by a teleporter to a single warehouse of the supply department. A warehouse holds at most one teleporter, so each sleigh needs its own warehouse.
The supply department manages n warehouses placed on a straight line. You must pick k of them for the teleporters and move all presents from the remaining warehouses into the chosen ones.
Warehouse i sits at position xi and holds wi tons of presents. The presents of one warehouse cannot be split, so they all move at once into one other warehouse. Moving w tons from the warehouse at xi to the warehouse at xj costs ∣xi−xj∣×w.
Santa Corporation wants to spend as little as possible. Pick the k warehouses so that the total moving cost is minimum, and report that cost.