There is just one road connecting the cities consecutively. You want to go from to stopping at most times to fill the tank of the car. There are gas stations at the cities, but none on the roads. The length of each road is . Which is the minimum range for your car? Suppose that you start with a full tank.
Input consists of several cases. Every case begins with and , which are followed by natural numbers . Suppose , , and .
For every case, print the minimum range for a car to reach starting from stopping at most times to fill the tank.
Consider a decisional version of this problem.
Input
5 0 100 300 500 200 400 5 1 100 300 500 200 400 5 2 100 300 500 200 400 5 3 100 300 500 200 400 5 4 100 300 500 200 400
Output
1500 900 600 500 500