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

/*

dp[1]=0
dp[i]= \max_{j=1}^{i-1} min(dp[j]+(hi-hj)^2+c)
dp[i]= dp[j] + h[i]^2 -2h[i]h[j] + h[j]^2 + c
dp[i] + h[i]^2 - c = dp[j] + h[j]^2 - 2h[i]h[j]

A = dp[i] + h[i]^2 - c
B = dp[j] + h[j]^2
C = 2h[i]

A = B - Ch[j]
B = Ch[j] + A

we want min A

let y = B, x = h[j]

y = Cx + A

*/

typedef long long LL;
const int M=2e5+5;

LL h[M];

LL dp[M];

int n;
LL c;

int qu[M],l,r;

inline LL getdp(int j,int i)
{
	return dp[j]+(h[i]-h[j])*(h[i]-h[j])+c;
}

inline LL y(int i)
{
	return dp[i]+h[i]*h[i];
}
inline bool check(int i,int j,int k)
{
	LL xi=h[i],yi=y(i);
	LL xj=h[j],yj=y(j);
	LL xk=h[k],yk=y(k);
	// (xi-xj)/(yi-yj) >= (xi-xk)/(yi-yk)
	return (xi-xj)*(yi-yk) >= (xi-xk)*(yi-yj);
}

int main()
{
	scanf("%d%lld",&n,&c);
	for(int i=1;i<=n;i++)
		scanf("%lld",&h[i]);
	l=r=0;
	qu[r++]=1;
	for(int i=2;i<=n;i++)
	{
		while(r-l>1&&getdp(qu[l],i)>=getdp(qu[l+1],i))
			l++;
		dp[i]=getdp(qu[l],i);
		while(r-l>1&&check(i,qu[r-1],qu[r-2]))
			r--;
		qu[r++]=i;
	}
	printf("%lld\n",dp[n]);
	return 0;
}