#include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T = ::std::int64_t, class Compare = ::std::less<T>>
class LiChaoTree{
private:
	static Compare comp;
	using size_type = ::std::size_t;

	struct Line{
		T a, b;
		bool used;
		Line() : a(0), b(0), used(false) {}
		Line(const T &a_, const T &b_) : a(a_), b(b_), used(true) {}
		T operator()(const T &x) { return a*x+b; }
	};

	size_type n, cnt;
	::std::vector<Line> node;
	::std::vector<T> pos;

	void add(size_type l, size_type r, const Line &line){
		cnt++;
		size_type l0 = l, r0 = r;
		size_type sz = 1;
		for (l += n, r += n; l < r; l >>= 1, r >>= 1, sz <<= 1) {
			if (l & 1) add(l, l0, l0+sz, line), l0 += sz, l++;
			if (r & 1) --r, r0 -= sz, add(r, r0, r0+sz, line);
		}
	}

	void add(size_type k, size_type l, size_type r, Line line){
		if (!node[k].used) {
			node[k] = line;
			return;
		}
		T ly = line(pos[l]), ry = line(pos[r-1]);
		T nly = node[k](pos[l]), nry = node[k](pos[r-1]);
		if (comp(nly, ly) && comp(nry, ry)) return;
		if (comp(ly, nly) && comp(ry, nry)) {
			node[k] = line;
			return;
		}
		if (r - l == 1) return;
		size_type m = (l + r) >> 1;
		if (comp(nly, ly)) swap(node[k], line);
		if (comp(line(pos[m]), node[k](pos[m]))) {
			swap(node[k], line);
			add((k << 1) | 1, m, r, line);
		} else {
			add(k << 1, l, m, line);
		}
	}
public:
	LiChaoTree(){}
	LiChaoTree(const ::std::vector<T> &v) : pos(v), cnt(0) {
		n = 1;
		while (n < pos.size()) n <<= 1;
		sort(pos.begin(), pos.end());
		pos.erase(unique(pos.begin(), pos.end()), pos.end());
		pos.resize(n, pos.back());
		node.resize(n << 1);
	}

	void add(T a, T b){
		add(0, n, Line(a, b));
	}

	void add(T a, T b, T lx, T rx){
		size_type l = lower_bound(pos.begin(), pos.end(), lx) - pos.begin();
		size_type r = lower_bound(pos.begin(), pos.end(), rx) - pos.begin();
		add(l, r, Line(a, b));
	}

	::std::pair<bool, T> query(T x) {
		Line l = get(x);
		return ::std::make_pair(l.used, l(x));
	}

	Line get(T x){
		size_type i = lower_bound(pos.begin(), pos.end(), x) - pos.begin() + n;
		size_type res = -1;
		for(; i > 0; i >>= 1){
			if (node[i].used)
				if (res == -1 || comp(node[i](x), node[res](x))) res = i;
		}
		return res == -1 ? Line() : node[res];
	}

	size_type size() { return cnt; } // the number of lines
};

template<class T, class Compare>
Compare LiChaoTree<T, Compare>::comp;

const int64 mod = 1e9+7;


int main(void){
	int64 N, C;
	cin >> N >> C;
	vector<int64> h(N+1);
	REP(i, N) cin >> h[i];
	vector<int64> dp(N+1, INF_LL);
	LiChaoTree<> cht(h);

	dp[0] = 0;
	cht.add(-2*h[0], h[0]*h[0]+dp[0]+C);
	FOR(i, 1, N){
		dp[i] = cht.query(h[i]).sc + h[i]*h[i];
		cht.add(-2*h[i], h[i]*h[i]+dp[i]+C);
	}

	cout << dp[N-1] << endl;
}


Measured memory_bytes: 18680