#include<cstdio>
#include<iostream>
#include<queue>
using namespace std;
const int MAXN = 200010;
typedef long long ll;
ll n, c, h[MAXN], q[MAXN], f[MAXN], g[MAXN], head, tail;
inline double K(int x, int y){return double(1.0*((g[x]-g[y])/(h[x]-h[y])));}
int main()
{
	scanf("%lld%lld",&n,&c);
	for(int i=1;i<=n;i++)
		scanf("%lld",&h[i]);
	f[1] = 0; g[1] = f[1]+1ll*h[1]*h[1];
	head = 1, tail = 0;
	q[++tail] = 1;
	for(int i=2;i<=n;i++)
	{
		//在转移过程中，队列中必须有一个元素进行转移 
		while(head<tail&&K(q[head],q[head+1])<(h[i]<<1))//如果从下标比当前队首大的元素转移会更优  
			head++;//则选用下一个比当前队首大的元素，即队列中排第二的元素 
		int j = q[head];
		f[i] = f[j]+1ll*(h[i]-h[j])*(h[i]-h[j])+c;
		g[i] = f[i]+1ll*h[i]*h[i];
		while(head<tail&&K(q[tail], i)<K(q[tail-1], q[tail]))//维护下凸壳的单调性
			tail--; 
		q[++tail] = i; 
	}
	printf("%lld\n",f[n]);
	return 0;
}