//By Tushar Gautam
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define leadzero(a) __builtin_clz(a) // count leading zeroes
#define trailzero(a) __builtin_ctz(a) // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln "\n"
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long int  ll;
typedef long double  ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM = 1e5+5, MOD = 1e9+7;
int t,n,m,k,x,y;
// const static int LX = -(1e9), RX = 1e9;
// struct Dynamic_Hull { /* Max hull */
//   struct Line{
//     ll m, c; // slope, intercept
//     Line(ll mm=0, ll cc=-1e18) { m = mm; c = cc; }
//     ll operator[](const int&x){ return m*x+c; }  
//   };
//   struct node {
//     node *lt,*rt; Line Ln;
//     node(const Line &l){lt=rt=nullptr; Ln=l;}
//   };
//   node *root=nullptr;
//   void add(Line l,node*&it,int lx=LX,int rx=RX){
//     if(it==nullptr)it=new node(l);
//     if(it->Ln[lx]>=l[lx] and it->Ln[rx]>=l[rx]) return;
//     if(it->Ln[lx]<=l[lx] and it->Ln[rx]<=l[rx]) {it->Ln=l; return;}
//     int mid = (lx+rx)>>1;
//     if(it->Ln[lx] < l[lx]) swap(it->Ln,l);
//     if(it->Ln[mid] >= l[mid]) add(l,it->rt,mid+1,rx);
//     else { swap(it->Ln,l); add(l,it->lt,lx,mid); }
//   }
//   void add(const ll &m,const ll &c) { add(Line(m,c),root); }
//   ll get(int &x,node*&it,int lx=LX,int rx=RX){
//     if(it==NULL) return -1e18; // Max hull
//     ll ret = it->Ln[x];
//     int mid = (lx+rx)>>1;
//     if(x<=mid) ret = max(ret , get(x,it->lt,lx,mid));
//     else ret = max(ret , get(x,it->rt,mid+1,rx));
//     return ret;
//   }
//   ll get(int x){ return get(x,root); }
// };
struct  Hull{
  struct line {
    ll m,c;
    ll eval(ll x){return m*x+c;}
    ld intersectX(line l){return (ld)(c-l.c)/(l.m-m);}
    line(ll m,ll c): m(m),c(c){}
  };
  deque<line> dq;
  v32 ints;
  Hull(){ints.clear(); dq.clear(); }//forn(i,n) ints.pb(i); }
  // Dec order of slopes
  void add(line cur){
    while(dq.size()>=2 && cur.intersectX(dq[0])>=dq[0].intersectX(dq[1]))
      dq.pop_front();
    dq.push_front(cur);
  }
  void add(const ll &m,const ll &c){add(line(m,c));}
  // Gives Maximum
  // query sorted dec.
  ll getval(ll x){
    while(dq.size()>=2 && dq.back().eval(x)<=dq[dq.size()-2].eval(x))
      dq.pop_back();
    return dq.back().eval(x);
  }
  // arbitary query
  // ll getval(ll x,deque<line> &dq){
  //   auto cmp = [&dq](int idx,ll x){return dq[idx].intersectX(dq[idx+1])<x;};
  //   int idx = *lower_bound(ints.begin(),ints.begin()+dq.size()-1,x,cmp);
  //   return dq[idx].eval(x);
  // }
  //ll get(const ll &x){return getval(x,dq);}
};
int main(){
	fastio;
	ll c;
	cin>>n>>c;
	ll h[n];
	forn(i,n) cin>>h[i];
	ll dp[n];
	dp[n-1]=0;
	Hull H;
	H.add(h[n-1],-h[n-1]*h[n-1]);
	rforn(i,n-2){
		auto r= -H.getval(2*h[i]);
		dp[i]= h[i]*h[i]+c+r;
		H.add(h[i],-h[i]*h[i]-dp[i]);	
	}
	cout<< dp[0] <<ln;
	return 0;
}

Measured memory_bytes: 4992