Orange Shipping

Partition the ordered oranges into consecutive boxes of at most M to minimize the sum of K plus size times the size spread in each box.

Medium6Dynamic programmingSliding windowNo attempts yetTime limit1sMemory limit256 MB

Problem

Juicy Orange Industry (JOI) is a company that packs oranges into boxes and ships them.

JOI ships the NN oranges it has collected by putting them into boxes. The oranges are first laid out in a row on a conveyor belt in the factory. The oranges on the belt are numbered 11 through NN from the front, and the size of orange ii is AiA_i.

The next step is to put the oranges into boxes, in order from the front. The numbers of the oranges placed in one box must be consecutive.

One box holds at most MM oranges. The cost of filling a box is K+s×(ab)K + s \times (a - b), where aa is the largest orange size in that box, bb is the smallest size, and ss is the number of oranges in it. KK is the fee for packing a box and is the same for every box.

Given the oranges on the conveyor belt, the maximum number of oranges that one box holds, and the packing fee KK, write a program that finds the minimum total cost of packing all of the oranges.

Input

The first line contains the number of oranges NN (1N200001 \le N \le 20\,000), the maximum number of oranges in one box MM (1M10001 \le M \le 1\,000, MNM \le N), and the packing fee KK (0K10000000000 \le K \le 1\,000\,000\,000), separated by spaces.

Each of the next NN lines contains one orange size AiA_i (1Ai10000000001 \le A_i \le 1\,000\,000\,000), given in order.

Output

Print the minimum total cost of packing all of the oranges on the first line.