#include <bits/stdc++.h>

using namespace std;

int h[200005], que[400005], l, r;
long long dp[200005];

long long x(int id) {
	return dp[id] + 1LL * h[id] * h[id];
}

int main() {
	int n;
	long long C;
	
	scanf("%d%lld", &n, &C);
	
	for (int i = 0; i < n; i++) scanf("%d", &h[i]);
	
	for (int i = 1; i < n; i++) {
		while (r - l >= 2 && (x(que[r - 1]) - x(que[r - 2])) * (h[i - 1] - h[que[r - 1]]) > (x(i - 1) - x(que[r - 1])) * (h[que[r - 1]] - h[que[r - 2]])) r--;
		que[r++] = i - 1;
		while (r - l >= 2 && (x(que[l + 1]) - x(que[l])) < 2LL * h[i] * (h[que[l + 1]] - h[que[l]])) l++;
		
		dp[i] = dp[que[l]] + 1LL * (h[i] - h[que[l]]) * (h[i] - h[que[l]]) + C;
	}
	
	printf("%lld\n", dp[n - 1]);
}
