//f[i]=f[j]+h[i]^2+h[j]^2-2h[i]h[j]
//f[i]=h[i]^2+(f[j]+h[j]^2)-2*h[i]*h[j]
//g[i]=f[i]+h[i]^2
//f[i]=h[i]^2+g[j]-2*h[i]*h[j]
//g[j]-2*h[i]*h[j]>g[k]-2*h[i]*h[k](j<k)后一个更优 
//g[j]-g[k]>2*h[i]*(h[j]-h[k])
//(g[j]-g[k])/(h[j]-h[k])<2*h[i]
//满足小于时，后一个比前一个优
//因为h递增，后一个永远比前一个优，可以直接舍去
//cale(x,y)>cale(y,z)时(x<y<z)
//cale(y,z)<cale(x,y)<2*h[i]时z最优
//cale(x,y)>cale(y,z)>2*h[i]时x最优
//cale(x,y)>2*h[i]>cale(y,z)时 x或z优 
//总之和y无关
//所以保持斜率递增 
#include<cstdio>
long long g[200005],f[200005],c;
int n,q[200005],h[200005],l,r;
double cale(int j,int k)
{return(g[j]-g[k])*1.0/(h[j]-h[k]);}
long long sqr(int x){return 1ll*x*x;}
int main()
{
	scanf("%d%lld",&n,&c);q[l=r=1]=1;
	for(int i=1;i<=n;i++)scanf("%d",&h[i]);g[1]=sqr(h[1]);
	for(int i=2;i<=n;i++)
	{
		while(l<r&&cale(q[l],q[l+1])<=2*h[i])l++;
		f[i]=g[q[l]]+sqr(h[i])-2*1ll*h[i]*h[q[l]]+c;
		g[i]=f[i]+sqr(h[i]);
		while(l<r&&cale(q[r-1],q[r])>=cale(q[r],i))r--;
		q[++r]=i;
	}printf("%lld\n",f[n]);
}