Crossing the River

No attempts yetTime limit1sMemory limit256 MB

Problem

Doctor Nefario is leaving on a trip after a long stretch of work in his lab. On the way he has to cross a river. The river holds NN rocks laid out on a straight line to the far bank, and he can use them as stepping stones. The width of the river, meaning the whole distance he has to cover, is LL.

The doctor's scooter hovers but cannot jump far, so a longer jump needs a rocket booster. A booster costs more when it is stronger. A booster that jumps up to distance RR costs R2R^2. The booster works any number of times, but every jump costs another CC. For example, a booster of range 1010 used for five jumps costs 102+5×C=100+5C10^2 + 5 \times C = 100 + 5C in total.

He starts on the near bank at distance 00 and finishes on the far bank at distance LL. One jump moves him forward by at most RR, and he must land on a rock or on the far bank.

Given the width LL, the cost CC of one jump, and the positions of the NN rocks, find the minimum cost MM of crossing the river, the number of jumps JJ it takes, and the booster range RR.

Crossing the river

In the figure the doctor crosses a river of width 66. The rocks sit at distances 11, 22, 33, and 55. A booster of range 33 carries him across in two jumps.

The limits are 1L1091 \le L \le 10^9, 0C1060 \le C \le 10^6, and 0N<10000 \le N < 1000. A rock position is an integer greater than 00 and less than LL. The range RR is chosen as a positive integer. The values grow large enough to need 64-bit integers, and scanning every possible range does not fit in the time limit.

Input

The input holds several test cases. The first line of each test case has the integers LL, CC, and NN: the width of the river, the cost of one jump, and the number of rocks. Each of the next NN lines holds the position of one rock. The rocks are not always listed in order of position. The last line holds a single 00, and the input ends on that line.

Output

For each test case print the minimum cost of crossing the river on one line, in this format.

Minimum cost M achieved with J jumps of range R

MM is the minimum cost, RR is the range that reaches it, and JJ is the smallest number of jumps needed to cross with range RR. When several ranges reach the minimum cost, print the smallest of them as RR.