#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXN = 200005;
const LL MOD = 998244353;

LL N, C, s, t, h[MAXN], dp[MAXN];
int deq[MAXN];

bool useless(int a, int b, int c) {
	LL m1 = -2 * h[a], b1 = dp[a] + h[a] * h[a];
	LL m2 = -2 * h[b], b2 = dp[b] + h[b] * h[b];
	LL m3 = -2 * h[c], b3 = dp[c] + h[c] * h[c];
	if ((b2 - b3) / (m3 - m2) < (b1 - b2) / (m2 - m1)) return true;
	if ((b2 - b3) / (m3 - m2) > (b1 - b2) / (m2 - m1)) return false;
	return (b2 - b3) % (m3 - m2) * (m2 - m1) <= (b1 - b2) % (m2 - m1) * (m3 - m2);
}

LL f(int j, LL x) {
	return dp[j] + h[j] * h[j] - 2 * h[j] * x;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> N >> C;
	for (int i = 1; i <= N; i++) cin >> h[i];
	
	dp[1] = 0;
	for (int i = 2; i <= N; i++) {
		while (t - s >= 2 && useless(deq[t - 2], deq[t - 1], i - 1)) t--;
		deq[t++] = i - 1;
		
		while (t - s >= 2 && f(deq[s], h[i]) >= f(deq[s + 1], h[i])) s++;
		dp[i] = f(deq[s], h[i]) + h[i] * h[i] + C;
	}
	
	cout << dp[N] << "\n";
}
