#include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n,c;
	cin >> n >> c;
	int h[n],dp[n],s[n],top=0,l=0;
	for(int i=0;i<n;i++)
		cin >> h[i];
	dp[0]=h[0]*h[0],s[top]=0;
	for(int i=1;i<n;i++){
		dp[i]=dp[s[l]]-2*h[i]*h[s[l]];
		while(l<top){
			int x=dp[s[l+1]]-2*h[i]*h[s[l+1]];
			if(x<dp[i])dp[i]=x,l++;
			else break;
		}
		dp[i]+=2*h[i]*h[i]+c;
		while(top){
			int p=(dp[s[top]]-dp[s[top-1]])*(h[i]-h[s[top]]);
			int q=(dp[i]-dp[s[top]])*(h[s[top]]-h[s[top-1]]);
			if(p>=q)top--;
			else break;
		}
		s[++top]=i;
		if(l>top)l=top;
	}
	cout << dp[n-1]-h[n-1]*h[n-1] << endl;
}
