Police Operation
Difficulty: Hard

Roy is helping the police department of his city in crime fighting. Today, they informed him about a new planned operation.

Think of the city as a $2D$ plane. The road along the $X$-axis is very crime prone, because $n$ criminals live there. No two criminals live at the same position.

To catch these criminals, the police department has to recruit some police officers and give each of them USD $h$ as wages. A police officer can start his operation from any point $a$, drive his car to point $b$ in a straight line, and catch all the criminals who live on this way. The cost of fuel used by the officer's car is equal to the square of the euclidean distance between points $a$ and $b$ (Euclidean distance between points $(x_1,y_1)$ and $(x_2,y_2)$ equals to $\sqrt{ (x_1-x_2)^2 + (y_1-y_2)^2 }$ ).

The police department asks Roy to plan this operation. So Roy has to tell them the number of officers to recruit and the routes these officers should take in order to catch all the criminals. Roy has to provide this information while minimizing the total expenses of this operation.

Find out the minimum amount of money required to complete the operation.


Input Format:
The first line contains two integers $n$ $(0 \le n \le 2 \times 10^{6})$, number of criminals, and $h$ $( 0 \le h \le 10^{9} )$, the cost of recruiting a police officer. The next line contains $n$ space separated integers. The $i^{th}$ integer indicates the position of the $i^{th}$ criminal on $X$-axis (in other words, if the $i^{th}$ integer is $x$, then location of the $i^{th}$ criminal is $(x,0)$). The value of the positions are between $1$ and $10^9$ and are given in increasing order in the input.


Output Format:
Print the minimum amount of money required to complete the operation.


Sample Input:
    5 10
    1 4 5 6 9


Sample Output:
    34


Python 3 starter code:
#
# Complete the 'policeOperation' function below.
#
# The function is expected to return an INTEGER.
# The function accepts following parameters:
#  1. INTEGER h
#  2. INTEGER_ARRAY criminals
#

def policeOperation(h, criminals):
    # Write your code here




Reference solution (C++):
###C++  
```cpp  
/*
 * Bidhan Roy
 * University of Dhaka
 */

using namespace std;
#include <bits/stdc++.h>

#define sgn(x,y) ((x)+eps<(y)?-1:((x)>eps+(y)?1:0))
#define rep(i,n) for(int i=0; i<(n); i++)
#define mem(x,val) memset((x),(val),sizeof(x));
#define rite(x) freopen(x,"w",stdout);
#define read(x) freopen(x,"r",stdin);
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define pb push_back
#define clr clear()
#define inf (1<<28)
#define ins add
#define xx first
#define yy second
#define eps 1e-9

typedef long long i64;
typedef unsigned long long ui64;
typedef string st;
typedef vector < int > vi;
typedef vector < st > vs;
typedef map < int , int > mii;
typedef map < st , int > msi;
typedef set < int > si;
typedef set < st > ss;
typedef pair < i64 , i64 > pii;
typedef vector < pii > vpii;

#define mx 2000010

i64 First[mx], Second[mx];

vpii poly;

void add(i64 idx, pii x) {
    while(poly.size() - idx > 1) {
        int i = sz( poly ) - 2, j = sz( poly ) - 1;
        i64 a = poly[j].yy - poly[i].yy ;
        i64 b = poly[i].xx - poly[j].xx ;
        i64 c = poly[j].yy - x.yy ;
        i64 d = x.xx - poly[j].xx ;
        if( a/b < c/d ) {
            poly.pop_back();
            continue;
        }
        break;
    }
    poly.pb(x);
}

#define which(v,x) ( v.yy + x * v.xx )

int main() {
    ios_base::sync_with_stdio(0);
    i64 n, k;
    cin >> n >> k ;
    if( !n || !k ) {
        cout << 0 << endl;
        return 0;
    }
    rep(i,n) cin >> First[i];
    poly.pb({-(First[n-1]<<1),sqr(First[n-1])});
    i64 res=0;
    for(int i = n - 1 , idx = 0; i >= 0 ; i--) {
        while( sz(poly)-idx > 1 && which(poly[idx], First[i]) > which(poly[idx+1], First[i])) idx++;
        res = k + sqr( First[i] ) + which(poly[idx], First[i]);
        add(idx, {-(First[i-1]<<1), res+sqr(First[i-1])});
    }
    cout << res << endl;
    return 0;
}
```