#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}


template<class T> class ConvexHullTrick {
private:
    deque<pair<T,T>> lines;
	function<int(T,T)> funcCompare;

	//cが必要かどうか判定する
    inline int isRequired(const pair<T,T>& l, const pair<T,T>& c, const pair<T,T>& r) {
        return (c.first - l.first) * (r.second - c.second) >= (c.second - l.second) * (r.first - c.first);
    }
    
	//k番目のax+bの値
    inline T value(int k, T x) {
        return lines[k].first * x + lines[k].second;
    }

public:
	ConvexHullTrick(function<int(T,T)> funcCompare) : funcCompare(funcCompare) {
		// do nothing
	} 

	//傾きの大きさが単調な順にax+bを追加
	void insert(T a, T b) {
		//insertの必要がないとき
        if(lines.size() && lines.back().first == a && lines.back().second <= b) return;
		// 直前の直線の傾きが同じ　かつ　それが必要ないとき
		if(lines.size() && lines.back().first == a && lines.back().second > b ) lines.pop_back();
		//不必要な直線を取り除く
		while (lines.size() > 1 && isRequired(lines[lines.size()-2], lines[lines.size()-1], {a,b})) lines.pop_back();
		lines.push_back({a,b});
    }
    
    T get(T x) {
        int ng = -1, ok = (int)lines.size()-1, md;
        while (ok - ng > 1) {
            md = (ok + ng) >> 1;
            ( funcCompare(value(md, x),value(md + 1, x)) ?ok:ng)=md;
        }
        return value(ok, x);
    }
    
    // クエリの単調性も成り立つ場合 (x が単調増加)
    T getMonotone(T x) {
        while (lines.size() >= 2 && value(0, x) >= value(1, x)) lines.pop_front();
        return lines[0].first * x + lines[0].second;
    }

};

//最小値クエリの時
//ConvexHullTrick<ll> cht([&](ll l, ll r){return l < r;});
//傾きがa1>=a2>=a3...となるようにinsertする

//最大値クエリの時
//ConvexHullTrick<ll> cht([&](ll l, ll r){return l > r;});
//傾きがa1<=a2<=a3...となるようにinsertする

//verify
//https://atcoder.jp/contests/colopl2018-final-open/tasks/colopl2018_final_c

int main() {
    ll N,C; cin >> N >> C;
    ConvexHullTrick<ll> cht([&](ll l, ll r){return l < r;});
    vector<ll> dp(N,0),h(N);
    for(int i = 0; i < N; ++i) cin >> h[i];
    cht.insert(-2*h[0],h[0]*h[0]);
    for(int i = 1; i < N; ++i) {
        dp[i] = cht.get(h[i]) + h[i]*h[i] + C;
        cht.insert(-2*h[i],dp[i]+h[i]*h[i]);
    }
    cout << dp[N-1] << endl;


    return 0;
}


Measured memory_bytes: 6656