#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
constexpr int mod = 1e9 + 7;
ll h[N], c, n;
ll dp[N];
double X(int i) { return h[i]; }
double Y(int i) { return dp[i] + h[i]*h[i]; }
double slope(int i, int j) { return (Y(j)-Y(i))/(X(j)-X(i)); }
int q[N], head = 1, tail = 1;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> c;
	for(int i=1; i<=n; i++) cin >> h[i];
	dp[1] = 0;
	q[tail++] = 1;
	for(int i=2; i<=n; i++)
	{
		dp[i] = (h[i]-h[1])*(h[i]-h[1])+c;
		while(head<tail && slope(q[head], q[head+1])<2*h[i]) head++;
		int j = q[head];
		dp[i] = min(dp[i], dp[j]+(h[i]-h[j])*(h[i]-h[j])+c);
		while(head<tail && slope(q[tail], i)<slope(q[tail-1],q[tail])) tail--;
		q[++tail] = i; 
	}
	cout << dp[n];
	return 0;
}