#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

using CHT_TYPE = ll;
struct CHT { //get min, if you want to get max, flip signs of a and b
	struct Line {
		CHT_TYPE a, b;
		mutable function<const Line*()> getSuc;

		bool operator<(const Line& rhs) const {
			if(rhs.b == IS_QUERY) {
				const Line* suc = getSuc();
				if(suc == nullptr) return false;
				const CHT_TYPE& x = rhs.a;
				return (suc->a - a) * x + suc->b - b > 0;
			}
			if(b == IS_QUERY) {
				const Line* suc = rhs.getSuc();
				if(suc == nullptr) return true;
				const CHT_TYPE& x = a;
				return (suc->a - rhs.a) * x + suc->b - rhs.b < 0;
			}
			return a < rhs.a;
		}
	};

	struct LinesSet: public multiset<Line> {
		inline bool isBad(iterator l) {
			const auto&& nel = next(l);
			if(l == begin()) {
				if(nel == end()) return false;
				return l->a == nel->a && l->b <= nel->b;
			}
			else {
				const auto&& prl = prev(l);
				if(nel == end()) return l->a == prl->a && l->b <= prl->b;
				return (prl->b - l->b) * (nel->a - l->a) 
					>= (nel->b - l->b) * (prl->a - l->a);
			}
		}

		inline void add(CHT_TYPE a, CHT_TYPE b) {
			auto&& it = insert({-a, -b});
			it->getSuc = [=] {
				return (next(it) == end() ? nullptr : &*next(it)); };
			if(isBad(it)) { erase(it); return; }
			while(next(it) != end() && isBad(next(it))) erase(next(it));
			while(it != begin() && isBad(prev(it))) erase(prev(it));
		}

		inline CHT_TYPE get(CHT_TYPE x) {
			auto&& l = *lower_bound(Line{x, IS_QUERY});
			return -l.a * x - l.b;
		}
	};

	static const CHT_TYPE IS_QUERY = numeric_limits<CHT_TYPE>::lowest();
	LinesSet linesSet;

	inline void add(CHT_TYPE a, CHT_TYPE b) { linesSet.add(a, b); }
	inline CHT_TYPE get(CHT_TYPE x) { return linesSet.get(x); }
	inline bool empty() { return linesSet.empty(); }
};

int N;
ll C;
ll H[MAX_N];
ll dp[MAX_N];
CHT cht;

void solve() {
	cin >> N >> C;
	rep(i, 0, N) cin >> H[i];
	cht.add(-2 * H[0], H[0] * H[0]);
	rep(i, 1, N) {
		dp[i] = H[i] * H[i] + C + cht.get(H[i]);
		cht.add(-2 * H[i], H[i] * H[i] + dp[i]);
	}
	cout << dp[N - 1] << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 22656