#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int n;
ll c,h[310000],dp[310000];
struct node{
	ll x,y;
}q[310000];
int main(){
	cin>>n>>c;
	for(int i=1;i<=n;++i){
		cin>>h[i];
	}
	int r=0,f=1;
	q[++r]=(node){-2*h[1],h[1]*h[1]};
	for(int i=2;i<=n;++i){
		while(f<=r&&h[i]*q[f+1].x+q[f+1].y<h[i]*q[f].x+q[f].y){
			f++;
		}
		dp[i]=q[f].y+h[i]*q[f].x+h[i]*h[i]+c;
		ll x=-2*h[i],y=dp[i]+h[i]*h[i];
		while(f<=r&&(y-q[r].y)*(q[r].x-q[r-1].x)>(x-q[r].x)*(q[r].y-q[r-1].y)){
			r--;
		}
		q[++r]=(node){x,y};
	}
	cout<<dp[n]<<'\n';
	return 0;
}