#include "bits/stdc++.h"

#define int long long

#define sqr(x) ((x) * (x))

using namespace std;

int32_t main() {
    ios_base::sync_with_stdio(0);
    int n, c;
    cin >> n >> c;
    vector<int> x(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    vector<int> d(n);
    d[0] = 0;
    vector<pair<int, int>> a;
    a.push_back({0, 0});
    for (int i = 1; i < n; i++) {
        int ind = upper_bound(a.begin(), a.end(), make_pair(x[i], (int)(2e18))) - a.begin() - 1;
        int j = a[ind].second;
        d[i] = d[j] + sqr(x[i] - x[j]) + c;
        while (a.size() && 
                            d[i] + sqr(x[i] - a.back().first) + c <= 
                            d[a.back().second] + sqr(x[a.back().second] - a.back().first) + c) {
            a.pop_back();
        }
        if (a.size() == 0) {
            a.push_back({0, i});
        } else {
            int inter = (d[i] + sqr(x[i]) - d[a.back().second] - sqr(x[a.back().second]) + 2 * x[i] - 2 * x[a.back().second] - 1)
                                                                                        / (2 * x[i] - 2 * x[a.back().second]);
            a.push_back({inter, i});
        }
    }
    cout << d.back() << endl;
}
