#include <bits/stdc++.h>
#define va first
#define vb second
#define lb lower_bound
#define pb push_back
#define all(v) v.begin(),v.end()
#define sz(v) ((int)v.size())
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
using ll = long long;
using lf = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

struct CHT{
    vector<pll> P;
    inline ll f(pll t, ll x){
        return t.va * x + t.vb;
    }
    lf get_cross(pll q, pll r){
        return lf(r.vb - q.vb) / (q.va - r.va);
    }
    int p = 0;
    void ins(pll t){
        while(P.size() > 1 && get_cross(t,P[sz(P)-2]) > get_cross(t,P[sz(P)-1])) P.pop_back();
        P.push_back(t);
        p = min(p, sz(P) - 1);
    }
    ll func(ll x){
        while(p + 1 < P.size() && f(P[p+1], x) <= f(P[p], x)) ++p;
        return f(P[p], x);
    }
} C;

int n;
ll h[200005], d[200005];
ll X;

int main(){
    fio;
    cin >> n >> X;
    for(int i = 1; i <= n; i++) cin >> h[i];
    for(int i = 2; i <= n; i++){
        C.ins({-2ll * h[i-1], d[i-1] + h[i-1] * h[i-1]});
        d[i] = h[i] * h[i] + X + C.func(h[i]);
    }
    cout << d[n] << '\n';
}