#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).scegin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}


template<typename T> 
struct CHT{
  using L=pair<T,T>;

  int type;//min:-1 max:1
  bool q_inc;//x in queries are increasing
  CHT(int _type,bool _q_inc):type(_type),q_inc(_q_inc){}

  deque<L> lines;//a is non-decreasing(max),non-increasing(min)

  static bool need(L l,L mid,L r){
    return (l.sc-mid.sc)*(r.fs-mid.fs)<(mid.fs-l.fs)*(mid.sc-r.sc);
  }//Is mid necessarry?


  void insert_front(L l){
    if(l.fs==lines[0].fs){
      if(type*l.sc<=type*lines[0].sc)return;
      else lines.pop_front();
    }
    while(2<=lines.size() && !need(l,lines[0],lines[1])){
      lines.pop_front();
    }
    lines.push_front(l);
  }

  void insert_back(L l){
    if(l.fs==lines.back().fs){
      if(type*l.sc<=type*lines.back().sc)return;
      else lines.pop_back();
    }
    while(2<=lines.size() && !need(lines[lines.size()-2],lines.back(),l)){
      lines.pop_back();
    }
    lines.push_back(l);
  }

  void insert(L l){
    if(lines.empty()){
      lines.push_back(l);
      return ;
    }
    if(type*l.fs<=type*lines[0].fs)insert_front(l);
    else if(type*lines.back().fs<=type*l.fs)insert_back(l);
    else assert(0);
  }
  void insert(T a,T b){insert(L{a,b});}

  inline T value(L l,T x){
    return l.fs*x+l.sc;
  }

  T get_minmax(T x){//x must be monotonical
    assert(lines.size());

    if(q_inc){//
      while(2<=lines.size() && type*value(lines[0],x)<=type*value(lines[1],x)){
        lines.pop_front();
      }
      return value(lines.front(),x);
    }else{
      while(2<=lines.size() && type*value(lines[(int)lines.size()-2],x)>=type*value(lines.back(),x)){
        lines.pop_back();
      }
      return value(lines.back(),x);
    }
  }
};
/*static CHT
slope and x in queries must be monotonical */

ll dp[200010];

signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  ll n,c;cin>>n>>c;
  V<ll> h(n,0);
  rep(i,0,n)cin>>h[i];

  CHT<ll> cht(-1,true);

  rep(i,1,n){
    cht.insert(-2ll*h[i-1],h[i-1]*h[i-1] +dp[i-1]);
    dp[i]=cht.get_minmax(h[i]) + h[i]*h[i] +c;
  }

  cout<<dp[n-1]<<ENDL;

} 
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

// EDPC Z CHT

Measured memory_bytes: 5632