#include<bits/stdc++.h>
#define all(x) begin(x),end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << " " <<
#define X real()
#define Y imag()
using namespace std;
using ll=long long;
using point=complex<ll>;

const int MXN=200005;

int n,qh,h[MXN];
point hull[MXN];
ll dp[MXN],C;

bool ccw(point a,point b,point c){
  const point p=b-a,q=c-a;
  if(p.Y/p.X!=q.Y/q.X)return p.Y/p.X<q.Y/q.X;
  return p.Y%p.X*q.X<=q.Y%q.X*p.X;
}

void insert(point p){
  while(qh>=2&&ccw(p,hull[qh-1],hull[qh-2]))qh--;
  hull[qh++]=p;
}

ll sqr(int x){return(ll)x*x;}

ll query(int x){
  int lo=0,hi=qh-1;
  while(lo<hi){
    int md=(lo+hi)/2;
    ll r1=hull[md].X*x+hull[md].Y;
    ll r2=hull[md+1].X*x+hull[md+1].Y;
    if(r1>r2){
      lo=md+1;
    }else{
      hi=md;
    }
  }
  // dbg(hull[lo]);
  return hull[lo].X*x+hull[lo].Y+C;
}

int main(){
  scanf("%d%lld",&n,&C);
  for(int i=1;i<=n;++i)scanf("%d",h+i);
  insert({-2*h[n],sqr(h[n])});
  for(int i=n-1;i>=1;--i){
    // for(int i=0;i<qh;++i)cout<<hull[i]<<",";
    dp[i]=query(h[i])+sqr(h[i]);
    // dbg(dp[i]);
    insert({-2*h[i],dp[i]+sqr(h[i])});
  }
  printf("%lld\n",dp[1]);
}
