#include <bits/stdc++.h>
using namespace std;

const long long inf = 1e18;

struct line_t {
	int a; long long b;
	line_t(int a = 0,long long b = 0) : a(a), b(b) {}
	long long f(int x) { return 1LL * a * x + b; };
};

double slope(line_t ln1, line_t ln2) {
	return (double) (ln2.b - ln1.b) / (double) (ln2.a - ln1.a);
}

struct convex_hull {
	vector<line_t> lns;
	int ptr = 0;
	void add(int a,long long b) {
		line_t ln(a, b);
		while (lns.size() > 1 && slope(lns[lns.size() - 2], lns.back()) <= slope(lns[lns.size() - 2], ln)) lns.pop_back();
		lns.push_back(ln); ptr = min(ptr, int(lns.size()) - 1);
	}
	long long get(int x) {
		if (lns.empty()) return inf;
		while (ptr + 1 < int(lns.size()) && lns[ptr].f(x) > lns[ptr + 1].f(x)) ptr++;
		return lns[ptr].f(x);
	}
};

const int N = 200005;

int n;
long long C;
int h[N];
long long f[N];
convex_hull ch;

int main() {
	scanf("%d %lld", &n, &C);
	for (int i = 1; i <= n; ++i) {
		int h; scanf("%d", &h);
		f[i] = (i == 1 ? 0 : ch.get(h) + 1LL * h * h + C);
		ch.add(-2 * h, 1LL * h * h + f[i]);
	}
	printf("%lld\n", f[n]);
}