#include<bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int maxn = 240000;
LL h[maxn], dp[maxn];
set<pair<LL, int>, greater<pair<LL, LL>>> ch;
int main(){
	LL N, C;
	cin >> N >> C;
	for(int i = 1; i <= N; i += 1) cin >> h[i];
	ch.insert(make_pair(h[1], 1));
	for(int i = 2; i <= N; i += 1){
		int j = ch.upper_bound(make_pair(h[i], N + 1))->second;
		dp[i] = dp[j] + (h[i] - h[j]) * (h[i] - h[j]) + C;
		LL p = 0;
		for(auto it = ch.begin(); it != ch.end(); it = ch.erase(it)){
			j = it->second;
			//(dp[i] + (p - h[i])^2
			p = (dp[i] + h[i] * h[i] - dp[j] - h[j] * h[j]
				+ 2 * (h[i] - h[j]) - 1) / (2 * (h[i] - h[j]));
			if(p > it->first) break;
		}
		ch.insert(make_pair(max(p, h[i]), i));
	}
	cout << dp[N];
}