#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

template<class line_t, typename y_t, typename x_t, class F, const line_t& I_L>
struct LiChaoTree {
    const F op = F();
    int n;
    vector<x_t> pos;
    vector<line_t> dat;
    void build(const vector<x_t>& pos_) {
        int n_ = pos_.size(); n = 1; while (n < n_) n *= 2; pos.resize(n);
        for (int i = 0; i < n_; ++i) pos[i] = pos_[i];
        for (int i = n_; i < n; ++i) pos[i] = pos[i - 1] + 1;
        dat.assign(2 * n, I_L);
    }
    void addLine(line_t line) { update(1, 0, n - 1, line); }
    void update(int k, int l, int r, line_t line) {
        y_t vlnew = line(pos[l]), vlold = dat[k](pos[l]);
        y_t vrnew = line(pos[r]), vrold = dat[k](pos[r]);
        if (op(vlnew, vlold) == vlold && op(vrnew, vrold) == vrold) return;
        if (op(vlnew, vlold) == vlnew && op(vrnew, vrold) == vlnew) { dat[k] = line; return; }

        int m = (l + r) / 2; y_t vmnew = line(pos[m]), vmold = dat[k](pos[m]);
        if (op(vmnew, vmold) == vmnew) swap(line, dat[k]), swap(vlnew, vlold);
        if (op(vlnew, vlold) == vlnew) update(k * 2, l, m, line);
        else update(k * 2 + 1, m + 1, r, line);
    }
    y_t query_x(x_t x) const {
        int i = lower_bound(pos.begin(), pos.end(), x) - pos.begin();
        assert(pos[i] == x); return query_index(i);
    }
    y_t query_index(int i) const { return query(1, 0, n - 1, i); }
    y_t query(int k, int l, int r, int i) const {
        y_t v = dat[k](pos[i]); if (l == r) return v;
        int m = (l + r) / 2;
        if (i <= m) return op(v, query(2 * k, l, m, i));
        else return op(v, query(2 * k + 1, m + 1, r, i));
    }
};

template<typename y_t, typename x_t, const y_t I_Y> struct Line {
    static constexpr Line<y_t, x_t, I_Y> identity = Line<y_t, x_t, I_Y>(0, I_Y);
    y_t a, b;
    constexpr Line(y_t a, y_t b) : a(a), b(b) {}
    bool operator ==(const Line<y_t, x_t, I_Y>& rhs) const {
        return a == rhs.a && b == rhs.b;
    }
    y_t operator ()(x_t x) const {
        return *this == identity ? I_Y : (x - a) * (x - a) + b;
    }
};
template<typename y_t, typename x_t, const y_t I_Y> constexpr Line<y_t, x_t, I_Y> Line<y_t, x_t, I_Y>::identity;
using L = Line<ll, int, INT64_MAX>;
template<typename T = int> struct min_of { constexpr T operator ()(T lhs, T rhs) const { return min<T>(lhs, rhs); } };

int main() {
    int N;
    ll C;
    cin >> N >> C;
    vector<int> h(N);
    rep(i, N) cin >> h[i];

    LiChaoTree<L, ll, int, min_of<ll>, L::identity> lct;
    lct.build(h);
    L lfirst(h[0], 0);
    lct.addLine(lfirst);
    rep(i, 1, N) {
        ll v = lct.query_index(i);
        L ladd(h[i], v + C);
        if (i != N - 1) lct.addLine(ladd);
        else write(v + C);
    }
}

Measured memory_bytes: 10368