#include<bits/stdc++.h>
#define rep(n) for(int i=0;i<(n);i++)
#define rep1(n) for(int i=1;i<=(n);i++)
#define all(n) n.begin(),n.end()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
using namespace std;
using ll=long long;
using pii=pair<ll,ll>;
#define pb push_back
ll n,c;
deque<pii> dq;
ll h[200005];
ll dp[200005];
ll val(pii li,ll x){
   return li.fi * x + li.se;
}
double xv(pii a, pii b){
  return (b.se - a.se)*1.0/(a.fi-b.fi);
}

int main(){
    ios::sync_with_stdio(0),cin.tie(0);
    cin>>n>>c;
    for(int i=1;i<=n;i++){
      cin>>h[i];
    }
    dp[1]=0;
    dq.push_back({-2*h[1],h[1]*h[1]});

    for(int i=2;i<=n;i++){
      while(dq.size()>=2 && val(dq[1],h[i]) < val(dq[0],h[i])) dq.pop_front();
      dp[i] = val(dq[0],h[i]) + h[i]*h[i] + c;
      pii tmp = {-2*h[i],h[i]*h[i]+dp[i]};
      while(dq.size()>=2 && xv(tmp,dq[dq.size()-2]) <= xv(dq[dq.size()-1],dq[dq.size()-2])) dq.pop_back();
      dq.push_back(tmp);
      //cout<<"%"<<i<<"\n";

      //cout<<dp[i]<<'\n';
    }
    cout<<dp[n]<<'\n';




}
