#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
// Convex-Hull Trick(Li Chao treeによる実装)
template <class T>
struct CHT {
    struct Line {
        T a, b;
        Line(T a_, T b_) : a(a_), b(b_) {}

        // xからy座標を返す
        T yp(T x) { return a * x + b; }
    };

    vector<T> xs;
    vector<Line> seg;
    int n;
    T id;
    bool isMin;
    function<bool(Line&, Line&, T)> comp;
    function<void(T &, T)> change;

    CHT(const vector<T> &xs_, bool isMin_ = true) : xs(xs_), isMin(isMin_) {
        n = 1;
        while (n < xs.size()) n *= 2;
        while (xs.size() < n) xs.emplace_back(xs.back() + 1);

        if (isMin) {
            id = numeric_limits<T>::max();
            comp = [](Line &f, Line &g, T x) { return g.yp(x) < f.yp(x); };
            change = [](T &t1, T t2) { t1 = min(t1, t2); };
        } else {
            id = numeric_limits<T>::min();
            comp = [](Line &f, Line &g, T x) { return g.yp(x) > f.yp(x); };
            change = [](T &t1, T t2) { t1 = max(t1, t2); };
        }
        seg.assign(2 * n, Line(0, id));
    }

    // seg[k], xsの半開区間[l, r)
    void update(Line &f, int k, int l, int r) {
        int mid = (l + r) / 2;
        bool lcomp = comp(seg[k], f, xs[l]), mcomp = comp(seg[k], f, xs[mid]), rcomp = comp(seg[k], f, xs[r - 1]);
        if (mcomp) swap(seg[k], f);

        if (l + 1 == r) return;
        else if(lcomp != mcomp)
            update(f, 2 * k + 0, l, mid);
        else if(mcomp != rcomp)
            update(f, 2 * k + 1, mid, r);
    }

    // 直線追加
    void add(T a, T b) {
        Line f(a, b);
        update(f, 1, 0, n);
    }

    T query(int k) {
        T x = xs[k];
        k += n;
        T ret = id;
        while (k > 0) change(ret, seg[k].yp(x)), k /= 2;
        return ret;
    }
};

int main() {
    init();
    ll N, C;
    cin >> N >> C;
    vl H(N);
    rep(i, N) cin >> H[i];
    CHT<ll> cht(H);

    cht.add(-2 * H[0], H[0] * H[0]);

    ll y = 0;
    repe(i, 1, N) {
        y = H[i] * H[i] + C + cht.query(i);
        cht.add(-2 * H[i], y + H[i] * H[i]);
    }

    cout << y << endl;
}

Measured memory_bytes: 15112