#include <iostream>
#include <algorithm>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
#define REP(i, a, b) for(i = a; i < b; i++)
using namespace std;

int INF = 1e+15;
int n, c;
int h[200000];
int dp[200000];

int cal(int i, int j) { return dp[i] + (h[i] - h[j]) * (h[i] - h[j]) + c; }

void calc(int l1, int r1, int l2, int r2) {
	if (l2 >= r2) return;
	int m = (l2 + r2) / 2;
	int i;
	
	int it = l1;
	REP(i, l1, r1) {
		if (cal(i, m) < cal(it, m)) {
			it = i;
		}
	}
	dp[m] = min(dp[m], cal(it, m));
	calc(l1, it + 1, l2, m);
	calc(it, r1, m + 1, r2);
}

void solve(int l, int r) {
	if (r - l <= 1) return;
	int m = (l + r) / 2;
	solve(l, m);
	calc(l, m, m, r);
	solve(m, r);
}

signed main() {
	int i;
	
	cin >> n >> c;
	rep(i, n) cin >> h[i];
	rep(i, n) dp[i] = INF;
	dp[0] = 0;
	solve(0, n);
	cout << dp[n - 1] << endl;
	return 0;
}