//minamoto
#include<bits/stdc++.h>
#define R register
#define inline __inline__ __attribute__((always_inline))
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=2e5+5;
typedef long long ll;
ll f[N],g[N],c;int n,h,t,hi[N],q[N];
inline double sl(R int i,R int j){return 1.0*(g[i]-g[j])/(hi[i]-hi[j]);}
int main(){
	scanf("%d%lld",&n,&c);
	fp(i,1,n)scanf("%d",&hi[i]);
	f[1]=0,g[1]=1ll*hi[1]*hi[1],q[h=t=1]=1;
	fp(i,2,n){
		while(h<t&&sl(q[h],q[h+1])<=2*hi[i])++h;
		f[i]=1ll*(hi[i]-hi[q[h]])*(hi[i]-hi[q[h]])+c+f[q[h]],
		g[i]=1ll*hi[i]*hi[i]+f[i];
		while(h<t&&sl(q[t-1],q[t])>sl(q[t-1],i))--t;
		q[++t]=i;
	}
	printf("%lld\n",f[n]);
	return 0;
}