#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 200001
ll q[N] = {0, 1}, f[N], h[N], n, c;
double slope(int i, int j) {
    return (f[i] - f[j] + h[i] * h[i] - h[j] * h[j]) / 2.0 / (h[i] - h[j]);
}
int main() {
    scanf("%lld%lld", &n, &c);
    for (int i = 1; i <= n; i++) scanf("%lld", &h[i]);
    int l = 1, r = 1;
    for (int i = 2; i <= n; i++) {
        while (l < r && slope(q[l], q[l + 1]) <= h[i]) l++;
        f[i] = f[q[l]] + (h[i] - h[q[l]]) * (h[i] - h[q[l]]) + c;
        while (l < r && slope(q[r - 1], q[r]) >= slope(q[r], i)) r--;
        q[++r] = i;
    }
    printf("%lld\n", f[n]);
    return 0;
}