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

int n;
long long C;
int h[200055];

// hi^2 - 2hihj + hj^2 + c
// -2hihj + hj^2 + hi^2 + c

int deq[200055];
long long dp[200055];

inline long long f(int i, int j) {
	return 1ll * (h[i] - h[j]) * (h[i] - h[j]) + dp[j] + C;
}
inline bool check(int i, int j, int k) {
	long long a1 = -2ll * h[i], b1 = dp[i] + 1ll * h[i] * h[i];
	long long a2 = -2ll * h[j], b2 = dp[j] + 1ll * h[j] * h[j];
	long long a3 = -2ll * h[k], b3 = dp[k] + 1ll * h[k] * h[k];
	
	return 1. * (a2 - a1) * (b3 - b2) >= 1. * (b2 - b1) * (a3 - a2);
}
int main() {
	cin >> n >> C;
	
	for (int i = 1; i <= n; i++) {
		scanf("%d", &h[i]);
	}
	
	int s = 0, t = 1;
	deq[s] = 1;
	
	for (int i = 2; i <= n; i++) {
		while (s + 1 < t && f(i, deq[s]) >= f(i, deq[s + 1])) {
			s++;
		}
		
		dp[i] = f(i, deq[s]);
		
		while (s + 1 < t && check(deq[t - 2], deq[t - 1], i)) {
			t--;
		}
		
		deq[t++] = i;
	}
	
	printf("%lld\n", dp[n]);
}
