# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 998244353;// 1000000000 + 7;
//constexpr long long INF = numeric_limits<LL>::max() / 2;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<vector<int>>g;
vector<edge>edges;
vector<Pll>v;
map<Pll, Pll>ma;
set<LL>st;
LL h, w, n, m, k, t, s, p, q, last, cnt, sum[100000], ans, a[210000], b[210000], dp[2100000];
string str, ss;
bool f;
char c;
template<typename T>
struct CHT {
	T INF = numeric_limits<T>::max();
	CHT() {
		// 番兵
		S.insert({ Line(INF,0), Line(-INF,0) });
		C.insert(cp(Line(INF, 0), Line(-INF, 0)));
	}
	// |ab| < LLONG_MAX/4 ???
	void add(T a, T b) {
		const Line p(a, b);
		It pos = S.insert(p).first;
		if (check(*prev(pos, 1), p, *next(pos, 1))) {
			// 直線(a,b)が不要
			S.erase(pos);
			return;
		}
		C.erase(cp(*prev(pos, 1), *next(pos, 1)));
		{
			// 右方向の削除
			It it = prev(pos, 1);
			while (it != S.begin() && check(*prev(it, 1), *it, p)) --it;
			C_erase(it, prev(pos, 1));
			S.erase(++it, pos);
			pos = S.find(p);
		}
		{
			// 左方向の削除
			It it = next(pos, 1);
			while (next(it, 1) != S.end() && check(p, *it, *next(it, 1))) ++it;
			C_erase(++pos, it);
			S.erase(pos, it);
			pos = S.find(p);
		}
		C.insert(cp(*prev(pos, 1), *pos));
		C.insert(cp(*pos, *next(pos, 1)));
	}
	T get(T x) {
		const Line &p = (--C.lower_bound(CP(x, 1, Line(0, 0))))->p;
		return p.a*x + p.b;
	}
private:
	struct Line {
		T a, b;
		Line(T a, T b) : a(a), b(b) {}
		bool operator<(const Line &rhs) const {
			return a != rhs.a ? a > rhs.a : b < rhs.b;
		}
	};
	struct CP {
		T n, d;
		Line p;
		CP(T _n, T _d, const Line &p) : n(_n), d(_d), p(p) {
			if (d < 0) { n *= -1; d *= -1; }
		};
		bool operator<(const CP &rhs) const {
			if (n == numeric_limits<T>::max()  || rhs.n == -numeric_limits<T>::max() ) return 0;
			if (n == -numeric_limits<T>::max()  || rhs.n == numeric_limits<T>::max() ) return 1;
			return n * rhs.d < rhs.n * d;
		}
	};

	typedef typename set<Line>::iterator It;
	set<Line> S;
	set<CP> C;
	void C_erase(It a, It b) {
		for (It it = a; it != b; ++it)
			C.erase(cp(*it, *next(it, 1)));
	}
	CP cp(const Line &p1, const Line &p2) {
		if (p1.a == INF) return CP(-INF, 1, p2);
		if (p2.a == -INF) return CP(INF, 1, p2);
		return CP(p1.b - p2.b, p2.a - p1.a, p2);
	}
	//false:p2 交わる true:p2 交わらない
	bool check(const Line &p1, const Line &p2, const Line &p3) {
		if (p1.a == p2.a && p1.b <= p2.b) return 1;
		if (p1.a == INF || p3.a == -INF) return 0;
		return (p2.a - p1.a)*(p3.b - p2.b) >= (p2.b - p1.b)*(p3.a - p2.a);
	}
};
int main() {
	CHT<LL> cht;
	cin >> n >> m;
	rep(i, n) {
		cin >> a[i];
	}
	dp[0] = 0;
	cht.add(-2 * a[0], dp[0] + a[0] * a[0]);
	for (int i = 1; i < n; i++) {
		dp[i] = a[i] * a[i] + m + cht.get(a[i]);
		cht.add(-2 * a[i], dp[i] + a[i] * a[i]);
	}
	cout << dp[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 33792