Covered Walkway

Time limit10sMemory limit128 MB

Problem

A university wants to build a new walkway, and at least part of it must be covered. There are certain points along the walkway that must be covered; whether any other points are covered or not does not matter.

The building contractor uses the following pricing scheme. To cover the walkway from a position $x$ to a position $y$, the contractor charges $c + (x - y)^2$, where $c$ is a constant. It is allowed that $x = y$, in which case the charge is simply $c$.

Given the points along the walkway and the constant $c$, find the minimum cost to cover every point that must be covered.

Input

The input contains several test cases. Each test case begins with a line containing two integers $n$ and $c$ ($1 \le n \le 1{,}000{,}000$, $1 \le c \le 10^9$), where $n$ is the number of points that must be covered and $c$ is the contractor's constant. Each of the following $n$ lines contains a single integer, a point along the walkway that must be covered. The points are given in order from smallest to largest. Every point is in the range from $1$ to $10^9$, inclusive. The input ends with a line containing two zeros (0 0).

Output

For each test case, output a single integer: the minimum cost to cover all of the specified points. Print each integer on its own line, with no spaces, and do not print any blank lines between answers. For every possible input, the answer fits in a signed 64-bit integer.