Land Division Tax

No attempts yetTime limit1sMemory limit128 MB

Problem

International Concrete Projects Company (ICPC) is a construction company that specializes in building houses for the high-end market. ICPC is planning a housing development of new homes around a lake. The houses will be built on lots of different sizes, but every lot lies on the lake shore. Moreover, every lot has exactly two neighbors in the development: one to its left and one to its right, so the lots form a ring around the lake.

ICPC owns the land around the lake and must divide it into lots according to the plan. The County Council, however, enforces a land-tax regulation meant to discourage the creation of small lots:

  1. land may only be divided through a sequence of land divisions;
  2. a land division is an operation that splits one piece of land into two pieces; and
  3. every land division is taxed.

Let $A$ be the area of the larger of the two parts produced by a division. The tax for that division is $A \times F$, where $F$ is the division tax factor set each year by the County Council. Because of rule (2), dividing one piece into $N$ lots requires $N - 1$ land divisions, so $N - 1$ payments must be made.

For example, suppose the factor is $2.5$ and the lots, in order around the lake, have areas $300, 100, 500, 100, 100, 200$. If the first division separates the lot of area $500$ from all the others, its tax is $2.5 \times (300 + 200 + 100 + 100 + 100)$, because the larger part has area $800$. If the next division then separates the lot of area $300$ together with its neighboring lot of area $100$ from the remaining lots, an additional $2.5 \times (300 + 100)$ is paid, and so on. Some divisions are impossible because of rule (2): after the first division above you cannot separate the lot of area $300$ together with the lot of area $200$ from the other three lots, since that would create more than two parts.

Given the areas of all lots around the lake and the current division tax factor, compute the smallest total land division tax needed to divide the land according to the plan.

Input

The input contains several test cases. The first line of a test case has an integer $N$ and a real number $F$: the number of lots ($1 \le N \le 200$) and the division tax factor (given with two decimal digits, $0 < F \le 5.00$). The second line has $N$ integers $X_i$, the areas of the contiguous lots in the plan ($0 < X_i \le 500$ for $1 \le i \le N$); lot $X_k$ neighbors lot $X_{k+1}$ for $1 \le k \le N - 1$, and lot $X_N$ neighbors lot $X_1$ (the lots form a ring). The end of the input is indicated by a line with $N = F = 0$.

Output

For each test case, print a single line with the minimum total land division tax, as a real number with exactly two decimal digits.