#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>

using namespace std;

struct line {
    double m/*-->slope*/, c/*-->y(0)*/;
    double eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};

int main(int argc, char const *argv[])
{
	int n;
	double h;
	long long C;
	cin >> n >> C;

	vector<line> dq;

	int i = 0;

	cin >> h;
	dq.push_back({-2*h, h * h});
	long long ans;
	for(int z = 1; z < n; z ++){
		cin >> h;

		while(dq.size() - 1 != i){
			if(dq[i].intersectX(dq[i+1]) > h) break;
			i ++;
		}
		double y = dq[i].eval(h);

		double fi = y + h*h + C;
		ans = fi;
		int j = dq.size() - 1;
		line l{-2*h, fi + h * h};
		while(dq[j].intersectX(dq[j-1]) >= l.intersectX(dq[j]) && j >= i){
			dq.pop_back();
			j --;
		}
		dq.push_back(l);
	}

	cout << ans;


	return 0;
}