#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
long long dp[200005];
pair<long long,long long> deq[200005];
long long h[200005];

int main(){
	int n;
	long long C;
	cin>>n>>C;
	for(int i=0;i<n;i++) cin>>h[i];
	dp[0]=0;
	int l=0,r=0;
	deq[0]=make_pair(h[0],dp[0]+h[0]*h[0]);
	for(int i=1;i<n;i++){
		while(r>=l+1&&deq[l+1].second-deq[l].second<=2*h[i]*(deq[l+1].first-deq[l].first)) l++;
		dp[i]=deq[l].second+h[i]*h[i]-2*h[i]*deq[l].first+C;
		long long x=h[i],y=dp[i]+h[i]*h[i];
		while(r>=l+1&&(y-deq[r-1].second)*(deq[r].first-deq[r-1].first)<=(deq[r].second-deq[r-1].second)*(x-deq[r-1].first)) r--;
	//	cout<<r<<endl;
		deq[++r]=make_pair(x,y);
	}
	cout<<dp[n-1];
}