#include<bits/stdc++.h>
using namespace std;
long long dp[323456];
long long k[323456], b[323456], vin, h[234567];
void dam(long long K, long long B){
    if(vin == 0) {k[1] = K, b[1] = B, vin++; return;}
    while(vin > 1){
        long long k1 = k[vin], b1 = b[vin];
        long long k2 = k[vin - 1], b2 = b[vin - 1];
        if((b2 - B) * (K - k1) > (b1 - B) *(K - k2)) vin --;
        else break;
    }
    vin++;
    k[vin] = K;
    b[vin] = B;
    
}
long long bam (long long X){
    long long lo = 1, hi = vin;
    while(lo  < hi){
        long long mid = (lo + hi + 1) / 2;
        if(k[mid] * X + b[mid] < k[mid - 1] * X + b[mid - 1])
            lo = mid;
        else hi = mid - 1;
    }
    return k[lo] * X + b[lo];

}
int main(){
    long long n, C;
    cin >> n >> C;
    for(long long i = 1;i <= n; i++)
        cin >> h[i];
    dp[1] = 0;
    dam(-2*h[1], h[1] * h[1]);
    for(long long i = 2; i <= n; i++){
        dp[i] = bam(h[i]) + h[i] * h[i] + C;
        dam(-2*h[i], h[i]*h[i] + dp[i]);
    }
    cout << dp[n] << endl;
    //(h[i]*h[i]) - 2h[i]h[j] + h[j]h[j]

}
