#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long
#define pb(a) push_back(a)
typedef long double ld;
typedef complex<ld> pt;
typedef vector<pt> pol;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ld> vd;
typedef vector<vd> vvd;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;
const ll INF = 0x3f3f3f3f;
const ll inf =  pow(10,18);
ll modulo = pow(10,9) + 7;
#define MAX (int)(2*pow(10,5) + 10)

ld EPS = 1e-9;

//*!
namespace n0 {
//*/
int sgn = 1; //set to 1 for lower envelope, -1 for upper envelope
struct line {
    ld m, b, left;
    line() : left(-INF) {}
    line(ld m, ld b) : m(m), b(b), left(-INF) {}
    ld eval(ld x) const { return m*x + b; }
    bool operator<(const line& o) const {
        if (m == o.m) return sgn*b < sgn*o.b;
        return sgn*m > sgn*o.m;
    }
    ld intersect(const line& o) const {
        if (abs(m-o.m) < EPS) return INF;
        return (o.b-b)/(m-o.m);
    }
};
struct comp_left {
    bool operator()(const line& l, const line& r) const {
        if (l.left == r.left) {
            if (l.m == r.m) return l.b < r.b;
            return l.m < r.m;
        }
        return l.left < r.left;
    }
};
struct envelope {
    set<line> lines;
    set<line, comp_left> top;
    ld query(ld x) {
        line l; l.left = x;
        set<line, comp_left>::iterator it = --top.lower_bound(l);
        return it->eval(x);
    }
    void recompute(line nl, line l, ld xl) {
        top.erase(nl);
        lines.erase(nl);
        if (nl.m != l.m) {
            nl.left = xl;
            top.insert(nl);
            lines.insert(nl);
        }
    }
    void insert(line l) {
        if (lines.size() == 1) {
            if (l < *lines.begin()) {
                recompute(*lines.begin(), l, l.intersect(*lines.begin()));
            } else {
                if (l.m == lines.begin()->m) return;
                l.left = l.intersect(*lines.begin());
            }
        } else if (lines.size() > 1) {
            auto i = lines.lower_bound(l);
            if (i != lines.begin() && i != lines.end()) {
                auto j = i; j--;
                ld x = i->intersect(*j);
                if (sgn*l.eval(x) >= sgn*(i->eval(x))) return;
            }
            for (int k = 0; k < 2; k++) {
                int s = (k ? -1 : 1);
                i = lines.lower_bound(l);
                bool bcond = (k ? i != lines.end() : i != lines.begin());
                if (!bcond) continue;
                auto j = i;
                if (k) j++;
                else { j = --i; j--; }
                while (true) {
                    bool econd = (k ? j == lines.end() : i == lines.begin());
                    ld x12 = i->intersect(l), x13 = j->intersect(l);
                    if (!econd && s*x13 > s*x12-EPS) {
                        auto it = i;
                        if (k) i++, j++;
                        else i--, j--;
                        top.erase(*it);
                        lines.erase(it);
                    } else {
                        if (k) recompute(*i, l, i->intersect(l));
                        else l.left = l.intersect(*i);
                        break;
                    }
                }
            }
        }
        lines.insert(l); top.insert(l);
    }
};
//*!
}

void deal(){
	ll n , c;
	cin>>n>>c;
	vector<ll> h(n);
	fori(n)
		cin>>h[i];
	vector<ll>  dp(n);
	n0::envelope all;
	fori(n){
		if(i == 0){
			dp[i] = 0;
			all.insert(n0::line(-2*h[i], h[i]*h[i] + dp[i] +c ));
			continue;
		}
		dp[i] = all.query(h[i]) + h[i]*h[i];
		all.insert(n0::line(-2*h[i], h[i]*h[i] + dp[i] +c ));
	//	cout<<dp[i]<<' ';
	}
	cout<<dp[n-1];
}

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}    

















Measured memory_bytes: 40832